Why electron app is not able to find correct path to a R file when packaged with asar flag?

305 views Asked by At

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

0

There are 0 answers