Repository navigation
fix: preserve relative symlink targets - #1964
pol-rivero wants to merge 1 commit into
Conversation
|
I think we should ensure as part of this behavior that:
|
|
@MarshallOfSound I think that adding this check could cause some problems:
I can add the check anyway, if you want. |
Upstream 3.6.7-beta3 moves to @electron/packager 20, whose copy of the app rewrites every relative link into an absolute path to the build machine, and works around it with derefSymlinks, which copies each link in full: the commands of the bundled git, links to a single binary, double the size of the installed app. On Linux, derefSymlinks is off again, and the copy keeps the links as written thanks to a patch of @electron/packager 20.3.0. The patch is the change proposed upstream in electron/packager#1964 by Pol Rivero, not yet released, carried as is into the compiled file the package ships. It goes away once a release includes it. macOS keeps the choice of upstream.
|
Adding a real-world data point, in case it helps weigh this PR. GitHub Desktop moved to I maintain a Linux build of GitHub Desktop (NitramO-YT/Github-Desktop) and saw the same thing there: the installed app went from 567 to 1139 MB, and the .rpm from 160 to 402 MB. The bundled git accounts for it: it ships most of its commands as relative links to a single binary ( With this PR's change applied to 20.3.0 through patch-package (Electron 44.1.1, Regarding the checks suggested above: in that packaged app, all 148 links are relative, resolve to an existing file and stay inside the app, so they would pass in this case. |
|
Note that this is also an issue here -- Would it make sense to roll the fix into this PR, or should I open a separate issue/PR/etc? |
Upstream 3.6.7 moves to @electron/packager 20, whose copy of the app rewrites every relative link into an absolute path to the build machine, and works around it with derefSymlinks, which copies each link in full: the commands of the bundled git, links to a single binary, double the size of the installed app. On Linux, derefSymlinks is off again, and the copy keeps the links as written thanks to a patch of @electron/packager 20.3.0. The patch is the change proposed upstream in electron/packager#1964 by Pol Rivero, not yet released, carried as is into the compiled file the package ships. It goes away once a release includes it. macOS keeps the choice of upstream. The same change has been on linux-beta since 3.6.7-beta3-linux1; the check of the bundled git in ci-linux.yml requires it here as well.
|
Chiming in from the GitHub Desktop team — we just got a user report about this in desktop/desktop#23236 and would love to see this merged! As @NitramO-YT noted above, when we upgraded from Since v18 preserved relative symlinks verbatim (via Thanks for putting this together, @pol-rivero! |
|
@pol-rivero would you mind to rebase this branch on top of the latest |
|
@sergiou87 @MarshallOfSound I've rebased the branch 👍 |
|
Thanks for the great work @pol-rivero and @sergiou87 , I didn't notice this PR when creating GitHub Desktop issue #23236 👍 |
|
Superseded by #1985. |
Summarize your changes:
Since v19.0.0 (#1821),
copyTemplate()copies the app withfs.promises.cpinstead of fs-extra'scopy(). Unlike fs-extra, Node'sfs.cpresolves relative symlink targets into absolute paths unlessverbatimSymlinks: trueis passed.As a result, with
derefSymlinks: false, a relative link in the app directory ends up in the packaged app as an absolute symlink, containing the full path of the project directory on the local machine. That link breaks as soon as the packaged app runs on any other machine.The only workaround is
derefSymlinks: true, which replaces every symlink with a full copy of its target, which is suboptimal as it can greatly increase the final size of the bundled app.This PR passes
verbatimSymlinks: !dereferencewhen copying the app, which restores the v18 behavior: symlinks are kept exactly as written.Please let me know if you want me to make any follow-up changes :)