develar / app-builder

Generic helper tool to build app in a distributable format
MIT License
122 stars 62 forks source link

Make symlink behavior configurable #141

Closed mat-sz closed 1 month ago

mat-sz commented 1 month ago

Symlink resolution behavior introduced in 189519a8292f939d9e5d3b47c6407444fee70334 breaks yarn workspaces.

Yarn tends to symlink things around when it comes to workspaces, so using any version after v5.0.0-alpha.3 results in an error similar to this (from electron-builder):

  ⨯ Path does not end with the package name  failedTask=build stackTrace=Error: Path does not end with the package name
    at getRealSource (/metastable/node_modules/app-builder-lib/src/util/appFileCopier.ts:194:13)
    at computeNodeModuleFileSets (/metastable/node_modules/app-builder-lib/src/util/appFileCopier.ts:225:24)
    at /metastable/node_modules/app-builder-lib/src/platformPackager.ts:401:34
    at async Promise.all (index 0)
    at AsyncTaskManager.awaitTasks (/metastable/node_modules/builder-util/src/asyncTaskManager.ts:65:25)
    at LinuxPackager.doPack (/metastable/node_modules/app-builder-lib/src/platformPackager.ts:293:5)
    at LinuxPackager.pack (/metastable/node_modules/app-builder-lib/src/platformPackager.ts:138:5)
    at Packager.doBuild (/metastable/node_modules/app-builder-lib/src/packager.ts:459:9)
    at executeFinally (/metastable/node_modules/builder-util/src/promise.ts:12:14)
    at Packager.build (/metastable/node_modules/app-builder-lib/src/packager.ts:393:31)
    at executeFinally (/metastable/node_modules/builder-util/src/promise.ts:12:14)

Reverting that change and rebuilding app-builder resolves those issues.

I can provide a minimal example if needed.

mmaietta commented 1 month ago

@beyondkmp can you please take a look at this when you have a chance?

beyondkmp commented 1 month ago

This has been fixed in https://github.com/electron-userland/electron-builder/pull/8560

mat-sz commented 1 month ago

@beyondkmp Thanks, I'll check it out once released and report back. Seems like it's a different problem and in my case it would break with a different directory structure (due to resolved symlinks), though.

beyondkmp commented 1 month ago

@mat-sz v25.1.8 has been released. You can help test it now if you have a chance.

mat-sz commented 1 month ago

@beyondkmp Different issue now, seems also related to symlinks:

 ⨯ /metastable/packages/metastable/eslint.config.js must be under /metastable/packages/client/  failedTask=build stackTrace=Error: /metastable/packages/metastable/eslint.config.js must be under /metastable/packages/client/
    at getRelativePath (/metastable/node_modules/app-builder-lib/src/util/filter.ts:32:13)
    at AsarPackager.unpackPattern (/metastable/node_modules/app-builder-lib/src/util/filter.ts:57:22)
    at AsarPackager.createPackageFromFiles (/metastable/node_modules/app-builder-lib/src/asar/asarUtil.ts:129:82)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at AsarPackager.pack (/metastable/node_modules/app-builder-lib/src/asar/asarUtil.ts:49:41)
    at /metastable/node_modules/app-builder-lib/src/platformPackager.ts:439:11
    at async Promise.all (index 0)
    at AsyncTaskManager.awaitTasks (/metastable/node_modules/builder-util/src/asyncTaskManager.ts:65:25)
    at LinuxPackager.doPack (/metastable/node_modules/app-builder-lib/src/platformPackager.ts:293:5)
    at LinuxPackager.pack (/metastable/node_modules/app-builder-lib/src/platformPackager.ts:138:5)
    at Packager.doBuild (/metastable/node_modules/app-builder-lib/src/packager.ts:459:9)
    at executeFinally (/metastable/node_modules/builder-util/src/promise.ts:12:14)
    at Packager.build (/metastable/node_modules/app-builder-lib/src/packager.ts:393:31)
    at executeFinally (/metastable/node_modules/builder-util/src/promise.ts:12:14)
beyondkmp commented 1 month ago

@mat-sz can you share a minimum reproducible repo for this by chance?

mat-sz commented 1 month ago

@beyondkmp

https://github.com/mat-sz/app-builder-workspace-bug-reproduction

Few notes:

  1. Further testing revealed that this issue is caused by putting a dependency of a workspace dependency in asarUnpack. In my real project I'm using this for sharp (native dependency). This happens with any dependency though, here: @example/client -> @example/common -> is-odd. The same setup wasn't a problem in the older version I mentioned.
  2. I'm testing this on Linux.
mmaietta commented 1 month ago

@mat-sz fix has landed in electron-builder v26.0.0-alpha.1. Please give it a shot when you have a chance

mat-sz commented 1 month ago

@mmaietta Thank you! Works perfectly fine on Linux.

I'll try it out on Windows and macOS tomorrow and let you know if everything is also fine there.

mat-sz commented 1 month ago

@mmaietta Apologies for the delayed response - everything works perfectly fine across all 3 platforms. Thank you once again.