0x80 / isolate-package

Isolate a monorepo package with its internal dependencies to form a self-contained directory with a pruned lockfile
MIT License
121 stars 13 forks source link

Failed to isolate due to pnpm pack #107

Closed BuyMyBeard closed 3 days ago

BuyMyBeard commented 4 days ago

I have tried to make my setup work for a firebase monorepo with isolate-package and firebase-tools-with-isolate, but It doesn't seem to work when running the command "isolate" in the deploy process.

I tried to clear my pnpm cache and reinstall my pnpm dependencies multiple times, but it didn't solve the problem.

Output of logLevel debug when running npx isolate ``` info Using isolate-package version 1.19.0 debug Found tsconfig at: ./tsconfig.json debug Workspace root resolved to W:\DevXpress\inspectogo debug Isolate target package (root)\packages\functions debug Isolate output directory (root)\packages\functions\isolate debug Cleaned the existing isolate output directory debug Detected package manager pnpm 9.12.1 debug Use PNPM pack instead of NPM pack debug Detected pnpm packages globs: [ 'packages/*' ] debug Registering package packages\security_rules debug Registering package packages\functions debug Registering package packages\firestore_models debug Registering package packages\admin_cli debug Packed (temp)/inspectogo_firestore_models-2.1.0.tgz debug Unpacking (temp)/inspectogo_firestore_models-2.1.0.tgz debug Moved package files to (isolate)\packages\firestore_models error Command failed: pnpm pack --pack-destination "W:\DevXpress\inspectogo\packages\functions\isolate\__tmp" Error: Command failed: pnpm pack --pack-destination "W:\DevXpress\inspectogo\packages\functions\isolate\__tmp" at genericNodeError (node:internal/errors:984:15) at wrappedFn (node:internal/errors:538:14) at ChildProcess.exithandler (node:child_process:422:12) at ChildProcess.emit (node:events:518:28) at maybeClose (node:internal/child_process:1105:16) at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5) ```

I also tried running the command earlier when I didn't have firebase-tools-with-isolate set up, and I was getting this error:

Output ``` Running command: pnpm isolate info Using isolate-package version 1.19.0 error Command failed: pnpm pack --pack-destination "W:\DevXpress\inspectogo\packages\functions\isolate\__tmp" Error: Command failed: pnpm pack --pack-destination "W:\DevXpress\inspectogo\packages\functions\isolate\__tmp" at genericNodeError (node:internal/errors:984:15) at wrappedFn (node:internal/errors:538:14) at ChildProcess.exithandler (node:child_process:422:12) at ChildProcess.emit (node:events:518:28) at maybeClose (node:internal/child_process:1105:16) at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5) node:events:496 throw er; // Unhandled 'error' event ^ Error: spawn pnpm isolate ENOENT at notFoundError (W:\DevXpress\inspectogo\node_modules\.pnpm\cross-spawn@6.0.5\node_modules\cross-spawn\lib\enoent.js:6:26) at verifyENOENT (W:\DevXpress\inspectogo\node_modules\.pnpm\cross-spawn@6.0.5\node_modules\cross-spawn\lib\enoent.js:40:16) at cp.emit (W:\DevXpress\inspectogo\node_modules\.pnpm\cross-spawn@6.0.5\node_modules\cross-spawn\lib\enoent.js:27:25) at ChildProcess._handle.onexit (node:internal/child_process:294:12) Emitted 'error' event on ChildProcess instance at: at cp.emit (W:\DevXpress\inspectogo\node_modules\.pnpm\cross-spawn@6.0.5\node_modules\cross-spawn\lib\enoent.js:30:37) at ChildProcess._handle.onexit (node:internal/child_process:294:12) { code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn pnpm isolate', path: 'pnpm isolate', spawnargs: [] } ```
isolate.config.json ``` { "targetPackagePath": "./packages/functions", "logLevel": "debug" } ```

The command runs perfectly fine though when I try to run it by hand: pnpm pack --pack-destination "W:\DevXpress\inspectogo\packages\functions\isolate\__tmp"

I am under the impression it breaks because it doesn't expect a local dependency. Could this be the case?

BuyMyBeard commented 4 days ago

Found the solution, should have RTFD.

https://github.com/0x80/isolate-package?tab=readme-ov-file#define-version-field-in-each-package-manifest

I think we should update the source code to pre-check whether the version is defined in package.json files, because it is pretty unintuitive to know this has to be done, and the error message is very generic.

I'll leave this open so owner sees it.

0x80 commented 3 days ago

Thanks for reporting and good to hear you found the solution. I agree that this should be detected.

It seems very much the same type of problem as this one https://github.com/0x80/isolate-package/issues/95

... so I will try to do both at once. (I have now changed that issue description)

0x80 commented 3 days ago

Closed in favor of #95