asar
asar copied to clipboard
--unpack-dir does not unpack symlinks
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.
After some testing, it seems that at https://github.com/electron/asar/blob/master/src/asar.coffee#L107:
shouldUnpackis never defined and used to check if the symlink should be unpacked.- nothing is being added to the
filesarray ifshouldUnpackends up being true (not sure if links should be added tofilesifshouldUnpackis false though as they seem to be treated differently inside an asar archive). copyFileToSyncis 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
shouldUnpackis true (meaning add them to thefilesarray, with maybe an additional propertyisLink: true). - They will then go through
copyFileToSync()and in there, check for.isSymbolicLink()and if true, copy the link usingfs.symlinkSync.
@kevinsawicki Thoughts?
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-httpsis just a symlink togit-remote-http. This can be disabled when compiling Git, but it results in duplicated binaries everywhere - and will result in a larger.asar.unpackedfolder when packaging the Electron app. -
Symlinks are added to the
.asarfile, but if your symlink is covered by the--unpack-dirargument, it won't be copied over to the.asar.unpackedfolder when creating the archive. -
Git explicitly looks for the symlink at runtime, and because it's been stripped out of the
.asar.unpackedarchive 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 :thumbsup: 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.
FYI @paulcbetts @smashwilson @binarymuse @kuychaco - why we won't currently be able to put Git into an ASAR
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