willviles / firebase-pnpm-workspaces

PNPM workspaces + Firebase deployments made easy
13 stars 1 forks source link

Error during copy dependencies #2

Open shinaBR2 opened 1 year ago

shinaBR2 commented 1 year ago

Hi @willviles first and foremost, thanks for your work when building this library, it will save tons of time for many future developers, I really appreciated that.

I faced the same problem here and end up trying this script with my public repository here. My repo is forked and built up from the turbo kitchen sink example

I tried to run on my repo the command pnpx firebase-pnpm-workspaces --filter api and got the following error

.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 1, reused 0, downloaded 0, adde.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 2, reused 2, downloaded 0, adde.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 5, reused 4, downloaded 0, adde.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 16, reused 12, downloaded 0, ad.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 34, reused 34, downloaded 0, ad.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 40, reused 39, downloaded 0, ad.../share/pnpm/store/v3/tmp/dlx-25000    |  +40 ++++
.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 40, reused 39, downloaded 0, ad.../share/pnpm/store/v3/tmp/dlx-25000    | Progress: resolved 40, reused 40, downloaded 0, added 40, done
Error: Cannot copy '../../../node_modules/.pnpm/ts-jest@26.5.6_we2p4sglclq5bmc4orivof3sv4/node_modules/ts-jest' to a subdirectory of itself, '../../../node_modules/.pnpm/ts-jest@26.5.6_we2p4sglclq5bmc4orivof3sv4/node_modules/ts-jest'.
    at /home/shinabr2/.local/share/pnpm/store/v3/tmp/dlx-25000/node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/copy/copy.js:213:21
    at FSReqCallback.oncomplete (node:fs:197:23)
 ERROR  Command failed with exit code 1: /home/shinabr2/.local/share/pnpm/store/v3/tmp/dlx-25000/node_modules/.bin/firebase-pnpm-workspaces --filter api

pnpm: Command failed with exit code 1: /home/shinabr2/.local/share/pnpm/store/v3/tmp/dlx-25000/node_modules/.bin/firebase-pnpm-workspaces --filter api
    at makeError (/home/shinabr2/.nvm/versions/node/v18.12.0/lib/node_modules/pnpm/dist/pnpm.cjs:22442:17)
    at handlePromise (/home/shinabr2/.nvm/versions/node/v18.12.0/lib/node_modules/pnpm/dist/pnpm.cjs:23013:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler [as dlx] (/home/shinabr2/.nvm/versions/node/v18.12.0/lib/node_modules/pnpm/dist/pnpm.cjs:188188:7)
    at async /home/shinabr2/.nvm/versions/node/v18.12.0/lib/node_modules/pnpm/dist/pnpm.cjs:195480:21
    at async main (/home/shinabr2/.nvm/versions/node/v18.12.0/lib/node_modules/pnpm/dist/pnpm.cjs:195451:34)
    at async runPnpm (/home/shinabr2/.nvm/versions/node/v18.12.0/lib/node_modules/pnpm/dist/pnpm.cjs:195645:5)
    at async /home/shinabr2/.nvm/versions/node/v18.12.0/lib/node_modules/pnpm/dist/pnpm.cjs:195637:7

I am still not sure what are the problems here, but as I read the source code from your library, maybe the problem occurred during copying the dependencies: https://github.com/willviles/firebase-pnpm-workspaces/blob/3fc319959cd045e1340ecc967b4ed11af4a24154/src/index.ts#L79

If you have time, you can check out my branch to give it a try, I will continue investigating this issue tomorrow.

Thanks!

shinaBR2 commented 1 year ago

I tried many hacks and cheat to bypass this issue and it still does not work:

This was a very frustrating experience. So I decided to temporarily not use the local workspace as a dependency of my Cloud Functions source code (in my case, the core workspace is only one dependency of the api workspace) , then I will get back to this later. You can instead check out this commit in case you may want to see the problem.