0

I'm trying to call R from JS in an electron app, which console logs the R version and pwd. It works perfectly when packaged without the asar flag using both electron-builder and electron-packager (see the following screenshot) enter image description here

However, when I build using asar yarn run build --asar, I do not get the expected output (See the following screenshot) enter image description here The main problem is that the app is not getting correct path to the R file (see the following screenshot).

enter image description here

Although, I have constructed the file path dynamically using path.

To reproduce the bug

  1. in windows 10, download the source code from this ftp link
  2. assuming you have vscode, node.js installed already, in vscode terminal from the ImShot_App_minimal folder run yarn install
  3. then run yarn run build --asar
  4. run the imshot-minimal-win32-x64\imshot-minimal.exe and in the console log check the path to the R file
  5. to get the expected result run step 4 but without --asar flag

What is the reason for getting wrong path? and how to fix this?

thanks

Wasim Aftab
  • 638
  • 1
  • 8
  • 16
  • Are you getting an actual error when working with the path? Some Node modules in Electron are patched in a way that they see `app.asar` as a virtual directory ([source](https://www.electronjs.org/docs/tutorial/application-packaging#node-api)). – snwflk Oct 16 '20 at 16:07
  • what exactly do you mean by actual error? I'm not sure how to debug the app other than console logging and from the console log its clear to me that the R path is very different when using asar that its counterpart. So, I thought that might be the reason. if you know any other way to figure out the actual error, please share. Thanks – Wasim Aftab Oct 16 '20 at 19:23

0 Answers0