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

--unpack-dir does not unpack symlinks #76

Closed
romaincointepas opened this issue Jul 20, 2016 · 5 comments
Closed

--unpack-dir does not unpack symlinks #76

romaincointepas opened this issue Jul 20, 2016 · 5 comments

Comments

@romaincointepas
Copy link

asar.unpackDir does not unpack symlinks into app.asar.unpacked/mydir (files and subdirectories are unpacked there, symlinks are not).

Tested with relative symlinks that points to files inside the directory that is being unpacked on OS X.

@romaincointepas romaincointepas changed the title asar.unpackDir does not unpack symlinks unpack-dir does not unpack symlinks Jul 20, 2016
@romaincointepas romaincointepas changed the title unpack-dir does not unpack symlinks --unpack-dir does not unpack symlinks Jul 20, 2016
@romaincointepas
Copy link
Author

romaincointepas commented Nov 5, 2016

After some testing, it seems that at https://github.com/electron/asar/blob/master/src/asar.coffee#L107:

  • shouldUnpack is never defined and used to check if the symlink should be unpacked.
  • nothing is being added to the files array if shouldUnpack ends up being true (not sure if links should be added to files if shouldUnpack is false though as they seem to be treated differently inside an asar archive).
  • copyFileToSync is then never called for links that should be unpacked

I would be happy to do a PR but I'm not sure I'm seeing the full picture (and all the potential edge cases when dealing with links). Here is how I would do it:

  • Treat links as files if shouldUnpack is true (meaning add them to the files array, with maybe an additional property isLink: true).
  • They will then go through copyFileToSync() and in there, check for .isSymbolicLink() and if true, copy the link using fs.symlinkSync.

@kevinsawicki Thoughts?

@stale stale bot added the wontfix label Mar 15, 2017
@shiftkey
Copy link

Just stumbled upon this issue as part of trying to package git into an ASAR archive while also dealing with the fact that Git is an executable.

A bit of context:

  • To reduce the overall size on disk, Git uses symlinks in many places - for example git-remote-https is just a symlink to git-remote-http. This can be disabled when compiling Git, but it results in duplicated binaries everywhere - and will result in a larger .asar.unpacked folder when packaging the Electron app.

  • Symlinks are added to the .asar file, but if your symlink is covered by the --unpack-dir argument, it won't be copied over to the .asar.unpacked folder when creating the archive.

  • Git explicitly looks for the symlink at runtime, and because it's been stripped out of the .asar.unpacked archive it'll fail in several hilarious ways.

Not sure if there's other context on this decision I'm missing or something that will break if we support this, but if there's a 👍 from someone on the core team about continuing down this path I'm happy to bash together a patch using what I've found and what @romaincointepas has found above.

@shiftkey
Copy link

FYI @paulcbetts @smashwilson @BinaryMuse @kuychaco - why we won't currently be able to put Git into an ASAR

@vyunikov
Copy link

Is there any progress on this issue?
I need to be able to unpack a framework on Mac and it doesn't work.
As Mac framework is a directory with multiple symlinks, skipping symlinks make framework structure invalid

@MarshallOfSound
Copy link
Member

Closing this old issue as it is likely fixed by now, if not please raise a new issue.

@MarshallOfSound MarshallOfSound closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants