0x80 / mono-ts

A quest for the perfect TS monorepo setup
MIT License
123 stars 10 forks source link

Fails on Windows without using WSL #16

Closed FelixRichter2000 closed 4 months ago

FelixRichter2000 commented 5 months ago

Issue Description

During the deployment of the api service using Firebase tools, the process fails with an error related to pnpm dependencies and an outdated lockfile. The error message indicates that the pnpm-lock.yaml file is not up to date with packages/common/package.json, causing the deployment to fail.

Steps to Reproduce

  1. Checkout Main Branch:

    • Switch to the main branch of the mono-ts repository.
  2. Install Dependencies:

    • Run pnpm install in the root directory.
  3. Navigate to API Service:

    • Change directory to services/api.
  4. Configure Firebase:

    • Create a Firebase project.
    • Set the project name in .firebaserc.
  5. Upgrade GCP Project:

    • Upgrade the GCP project to the BLAZE plan.
  6. Enable Secret Manager API:

    • Enable the "Secret Manager API" in the GCP console.
  7. Deploy API Service:

    • Execute the deploy task from services/api without the --project demo-mono-ts parameter.
    • Enter a secret when prompted during deployment.

Deployment Log

> firebase deploy --only functions

=== Deploying to 'my-actual-project-id'...

i  deploying functions
Running command: turbo build
• Packages in scope: @repo/api
• Running build in 1 packages
• Remote caching disabled
@repo/backend:build: cache hit, replaying logs 188a15c5f887936f
@repo/backend:build: 
@repo/backend:build: > @repo/backend@0.0.0 build C:\Users\myself\WebstormProjects\mono-ts\packages\backend
@repo/backend:build: > run-p bundle type:gen
@repo/backend:build: 
@repo/backend:build: 
@repo/backend:build: > @repo/backend@0.0.0 bundle C:\Users\myself\WebstormProjects\mono-ts\packages\backend
@repo/backend:build: > tsup-node
@repo/backend:build: 
@repo/backend:build: 
@repo/backend:build: > @repo/backend@0.0.0 type:gen C:\Users\myself\WebstormProjects\mono-ts\packages\backend
@repo/backend:build: > tsc --emitDeclarationOnly
@repo/backend:build: 
@repo/backend:build: CLI Building entry: {"utils/index":"src/utils/index.ts","firebase":"src/firebase.ts"}
@repo/backend:build: CLI Using tsconfig: tsconfig.json
@repo/backend:build: CLI tsup v8.0.2
@repo/backend:build: CLI Using tsup config: C:\Users\myself\WebstormProjects\mono-ts\packages\backend\tsup.config.ts
@repo/backend:build: CLI Target: es2022
@repo/backend:build: ESM Build start
@repo/backend:build: ESM dist\firebase.js        822.00 B
@repo/backend:build: ESM dist\utils\index.js     923.00 B
@repo/backend:build: ESM dist\firebase.js.map    1.52 KB
@repo/backend:build: ESM dist\utils\index.js.map 1.92 KB
@repo/backend:build: ESM ⚡️ Build success in 51ms
@repo/api:build: cache hit, replaying logs 02c60e416d86d2e8
@repo/api:build: 
@repo/api:build: > @repo/api@0.0.0 build C:\Users\myself\WebstormProjects\mono-ts\services\api
@repo/api:build: > tsup-node
@repo/api:build: 
@repo/api:build: CLI Building entry: src/index.ts
@repo/api:build: CLI Using tsconfig: tsconfig.json
@repo/api:build: CLI tsup v8.0.2
@repo/api:build: CLI Using tsup config: C:\Users\myself\WebstormProjects\mono-ts\services\api\tsup.config.ts
@repo/api:build: CLI Target: node18
@repo/api:build: CLI Cleaning output folder
@repo/api:build: ESM Build start
@repo/api:build: ESM dist\index.js     3.76 KB
@repo/api:build: ESM dist\index.js.map 8.94 KB
@repo/api:build: ESM ⚡️ Build success in 67ms

 Tasks:    2 successful, 2 total
Cached:    2 cached, 2 total
  Time:    1.135s >>> FULL TURBO

+  functions: Finished running predeploy script.
i  functions: preparing codebase api for deployment
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
+  artifactregistry: required API artifactregistry.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
+  functions: required API cloudbuild.googleapis.com is enabled
i  functions: Loading and analyzing source code for codebase api to determine what to deploy
Serving at port 8864

i  functions: Loaded environment variables from .env.
? This secret will be stored in Cloud Secret Manager (https://cloud.google.com/secret-manager/pricing) as DEMO_API_KEY. Enter a value for DEMO_API_KEY: [hidden]
i  functions: preparing . directory for uploading...
i  functions: Start isolating the source folder...
debug Using isolate-package version 1.14.0
debug Found tsconfig at: ./tsconfig.json
debug Workspace root resolved to C:\Users\myself\WebstormProjects\mono-ts
debug Isolate target package (root)/\services\api
debug Isolate output directory (root)/\services\api\isolate
debug Detected package manager pnpm 9.0.4+sha256.caa915eaae9d9aefccf50ee8aeda25a2f8684d8f9d5c6e367eaf176d97c1f89e
debug Use PNPM pack instead of NPM pack
debug Detected pnpm packages globs: [ 'apps/*', 'packages/*', 'services/*' ]
debug Registering package ./apps\web
debug Registering package ./packages\typescript-config
debug Registering package ./packages\eslint-config
debug Registering package ./packages\common
debug Registering package ./packages\backend
debug Registering package ./services\fns
debug Registering package ./services\api
debug Packed (temp)/repo-backend-0.0.0.tgz
debug Packed (temp)/repo-common-0.0.0.tgz
debug Unpacking (temp)/repo-backend-0.0.0.tgz
debug Unpacking (temp)/repo-common-0.0.0.tgz
debug Moved package files to (isolate)/\packages\common
debug Moved package files to (isolate)/\packages\backend
debug Packed (temp)/repo-api-0.0.0.tgz
info Generating PNPM lockfile...
debug Relevant importer ids: [ 'services/api', 'packages\\backend', 'packages\\common' ]
debug Setting target package importer on root
debug Pruning the lockfile
debug Created lockfile at C:\Users\myself\WebstormProjects\mono-ts\services\api\isolate\pnpm-lock.yaml
debug Deleting temp directory (root)/\services\api\isolate\__tmp
info Isolate completed at C:\Users\myself\WebstormProjects\mono-ts\services\api\isolate
i  functions: Finished isolation at C:\Users\myself\WebstormProjects\mono-ts\services\api\isolate
i  functions: packaged C:\Users\myself\WebstormProjects\mono-ts\services\api\isolate (53.43 KB) for uploading
i  functions: ensuring required API run.googleapis.com is enabled...
i  functions: ensuring required API eventarc.googleapis.com is enabled...
i  functions: ensuring required API pubsub.googleapis.com is enabled...
i  functions: ensuring required API storage.googleapis.com is enabled...
+  functions: required API pubsub.googleapis.com is enabled
!  functions: missing required API run.googleapis.com. Enabling now...
+  functions: required API storage.googleapis.com is enabled
!  functions: missing required API eventarc.googleapis.com. Enabling now...
+  functions: required API run.googleapis.com is enabled
+  functions: required API eventarc.googleapis.com is enabled
i  functions: generating the service identity for pubsub.googleapis.com...
i  functions: generating the service identity for eventarc.googleapis.com...
i  functions: ensuring 453676369314-compute@developer.gserviceaccount.com access to secret DEMO_API_KEY.
+  secretmanager: Granted roles/secretmanager.secretAccessor on projects/my-actual-project-id/secrets/DEMO_API_KEY to 453676369314-compute@developer.gserviceaccount.com
+  functions: ensured 453676369314-compute@developer.gserviceaccount.com access to DEMO_API_KEY.
+  functions: . folder uploaded successfully
i  functions: creating Node.js 20 (2nd Gen) function api:api(europe-west3)...

Build failed with status: FAILURE and message: installing pnpm dependencies: (error ID: 8622936f):
Scope: all 3 workspace projects
 ERR_PNPM_OUT

DATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with packages/common/package.json

Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"

    Failure reason:
    specifiers in the lockfile ({}) don't match specs in package.json ({"firebase":"^10.12.0","remeda":"^1.61.0"}). For more details see the logs at https://console.cloud.google.com/cloud-build/builds;region=europe-west3/34b9adb4-b996-415e-9d85-9584c161ce9f?project=453676369314.

Functions deploy had errors with the following functions:
        api:api(europe-west3)
i  functions: cleaning up build files...
!  functions: Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected. You can attempt to delete these images by redeploying or you can delete them manually at https://console.cloud.google.com/gcr/images/my-actual-project-id/eu/gcf

Error: There was an error deploying functions
 ELIFECYCLE  Command failed with exit code 2.
FelixRichter2000 commented 5 months ago

I just noticed this similar issue: https://github.com/0x80/mono-ts/issues/12#issuecomment-2030683506

I will try the WSL think next.

0x80 commented 5 months ago

Thanks for reporting this. Good to hear that you found a clue already.

Looking at the debug output it seems that definitely the paths are messed up, so likely that is related.

debug Workspace root resolved to C:\Users\myself\WebstormProjects\mono-ts
debug Isolate target package (root)/\services\api
debug Isolate output directory (root)/\services\api\isolate
debug Detected package manager pnpm 9.0.4+sha256.caa915eaae9d9aefccf50ee8aeda25a2f8684d8f9d5c6e367eaf176d97c1f89e
debug Use PNPM pack instead of NPM pack
debug Detected pnpm packages globs: [ 'apps/*', 'packages/*', 'services/*' ]
debug Registering package ./apps\web
debug Registering package ./packages\typescript-config
debug Registering package ./packages\eslint-config
debug Registering package ./packages\common
debug Registering package ./packages\backend
debug Registering package ./services\fns
debug Registering package ./services\api
debug Packed (temp)/repo-backend-0.0.0.tgz
debug Packed (temp)/repo-common-0.0.0.tgz
debug Unpacking (temp)/repo-backend-0.0.0.tgz
debug Unpacking (temp)/repo-common-0.0.0.tgz
debug Moved package files to (isolate)/\packages\common
debug Moved package files to (isolate)/\packages\backend
debug Packed (temp)/repo-api-0.0.0.tgz
info Generating PNPM lockfile...
debug Relevant importer ids: [ 'services/api', 'packages\\backend', 'packages\\common' ]

I have renamed the title, to make it clear that is likely about broader support for Windows.

Ultimately this is something that I need to fix as part of isolate-package, so I'll create an issue there.

FelixRichter2000 commented 5 months ago

It works with WSL for me and I would appreciate the windows support.

0x80 commented 5 months ago

@FelixRichter2000 I think I have solved the Windows incompatibilities in the latest version of isolate-package. Could you try again and see if it works for you?

0x80 commented 4 months ago

Assuming this is resolved