question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The asar unpacked files are accessible only with functions like spawn/exec, see https://github.com/electron/electron/issues/6262

See original GitHub issue
  • electron-builder v11.2.4:
  • ia32:

Hello,

There are two problems. The first one is that the regedit module is not saved automatically in app.asar.unpacked

The second problem is that it’s not really working even if I set manually the asarUnpack value.

builder.build ({
  // blabla
  config: {
    asarUnpack: [
      '**node_modules/regedit/**',
    ],
   }
  // blabla
})

The regedit module spawn/exec (I don’t know exactly) wsf and vbs scripts.

In the win.asar.unpacked directory I can find this module with all files. It looks perfect… C:\blabla\win-ia32-unpacked\resources\app.asar.unpacked\node_modules\regedit.

But when executing… it’s not working at all…

Input Error: Can not find script file "C:\blabla\win-ia32-unpacked\resources\app.asar\node_modules\regedit\vbs\regList.wsf".

Why the spawn/exec calls are not looking in the app.asar.unpacked directory? asarUnpack seems useless if it’s necessary to handle manually the location for the spawns. I’m doing something wrong?

Thanks for help Regards

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
Skywalker13commented, Jan 17, 2017

@develar I’ve make a module in order to handle this problem with only one line of code to add in the electron project, see https://github.com/epsitec-sa/hazardous

For example, with my sample:

'use strict';

require ('hazardous');
const regedit = require ('regedit');

regedit.list ('HKCU\\SOFTWARE', function (err, result) {
  if (err) {
    console.error (err);
    process.exit (1);
  }
  console.dir (result);
  process.exit (0);
});

The only thing to do is to add require ('hazardous'); at the beginning of the main script of the app. Then, the functions join(), resolve() and normalize() can return the unpacked location according to some conditions; just read the README for details.

1reaction
jononucommented, Jul 26, 2017

It feels like the hazardous library should be the normal behavior for these functions. Is there a reason it’s not?

In our case we’re exec’ing a java on the system and running a JAR file that’s packaged with the app. It’s convoluted but saved us development effort by not having to rewrite some functions in node.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting path to asar.unpacked · Issue #6262 - GitHub
The asar unpacked files are accessible only with functions like spawn/exec, see https://github.com/electron/electron/issues/6262 ...
Read more >
Allow ASAR to work with child_process.spawn() #9459 - GitHub
execFile, but only execFile is supported to execute binaries inside asar archive. This is because exec and spawn accept command instead of file...
Read more >
Unable to access a file inside asar pacakge #751 - GitHub
Version: 6.7.3 Target: Linux, Windows I have some scripts in my app, which I need to execute when application starts. I am allowing...
Read more >
child-process.spawn on exe in app.asar.unpacked causes ...
I expect to be able to invoke an exe which is in app.asar.unpacked ( C:\Program Files\MyElectronApp\resources\app.asar.unpacked\node_modules\ ...
Read more >
spawn() in combination with app.asar and app.asar.unpacked ...
See my issue on johnvmt/node-desktop-screenshot#7 where to code is explained. Short story: When packaging for windows target with electron 1.4.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found