Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency calling chdir #55

Closed
scholtzm opened this issue Feb 2, 2016 · 6 comments
Closed

Dependency calling chdir #55

scholtzm opened this issue Feb 2, 2016 · 6 comments

Comments

@scholtzm
Copy link

scholtzm commented Feb 2, 2016

One of my dependencies (a critical one) calls chdir. According to docs, working directory cannot be set.

How are others dealing with this issue? Is there any way around this?

@HZSamir
Copy link

HZSamir commented Dec 13, 2016

I am in the same boat as @scholtzm
Has there been any development since?

@scholtzm
Copy link
Author

scholtzm commented Dec 13, 2016

Interesting coincidence - I started digging into this issue only 2 days ago after months of break.

In my case, the dependency calls .chdir(__dirname) so I decided to use --unpack-dir flag to unpack this specific dependency. The result was:

  • app.asar.unpacked folder - this folder contains that one dependency I unpacked
  • app.asar file - according to asar list command, this file still contains the dependency as well 🤔

When the code is executing, __dirname points to folder inside app.asar (no idea why, it should be app.asar.unpacked ❓) and so it fails once again. If I place a breakpoint and modify __dirname to contain app.asar.unpacked, it works.

@scholtzm
Copy link
Author

@Unforgiven-wanda Comments here might interest you if you still haven't solved your problem: electron/electron#8206

Closing this since there's not much to be done here.

@HZSamir
Copy link

HZSamir commented Jan 15, 2017

@scholtzm Your answer kinda lost me there. Did you manage to monkey patch chdir for it to work inside ASAR? I'm not clear on that.

@scholtzm
Copy link
Author

scholtzm commented Jan 15, 2017

You can see my very specific monkey patch here: https://github.com/scholtzm/punk/blob/master/src/utils/monkey-patch.js

I override chdir with custom logic and then prepend path for a small set of files. Since chdir is now just a dummy function, it allows me to package everything inside an asar archive.

@HZSamir
Copy link

HZSamir commented Jan 16, 2017

Thank you @scholtzm This was exactly it.
Good day :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants