Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation step doesn't detect PNPM in a monorepo #4648

Closed
markgaze opened this issue Oct 20, 2022 · 3 comments
Closed

Installation step doesn't detect PNPM in a monorepo #4648

markgaze opened this issue Oct 20, 2022 · 3 comments
Assignees
Labels
type: bug code to address defects in shipped code

Comments

@markgaze
Copy link

Describe the bug

If you have a monorepo, you set the base directory to one of sub-directories which does not contain the pnpm-lock.yaml file, which is in the top-level directory. Therefore, Netlify doesn't detect PNPM and tries to install with NPM, which fails - in my use case with:

npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:*

Steps to reproduce

  1. Create a monorepo using PNPM (I'm also using Turborepo)
  2. Setup a Netlify project with one of the subdirectories as it's base directory
  3. Configure the build to cd back up to the top-level before running the build (see config)
  4. Run a build on Netlify

(I'm not sure 3 is necessary, as I think it will still fail to find the pnpm-lock.yaml file even if this isn't the case)

Configuration

[build]
command = "cd ../.. && NEXT_PUBLIC_REVIEW_ID=$REVIEW_ID NEXT_PUBLIC_BRANCH=$BRANCH pnpm build-docs --filter=\"docs\""

Deploy logs

2:41:52 PM: Build ready to start
2:41:55 PM: build-image version: d05976bd3309b73a86eaa327bf80e105ff13f5e4 (focal)
2:41:55 PM: build-image tag: v4.13.0
2:41:55 PM: buildbot version: a3df1bd789b72c6280ab972860704adbfa8b1f49
2:41:55 PM: Fetching cached dependencies
2:41:56 PM: Starting to download cache of 333.7MB
2:41:59 PM: Finished downloading cache in 3.138357703s
2:41:59 PM: Starting to extract cache
2:42:01 PM: Finished extracting cache in 1.963945185s
2:42:01 PM: Finished fetching cache in 5.1901731s
2:42:01 PM: Starting to prepare the repo for build
2:42:02 PM: Preparing Git Reference pull/274/head
2:42:04 PM: Parsing package.json dependencies
2:42:05 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'apps/docs/build' versus '.next' in the Netlify UI
2:42:05 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'cd ../.. && NEXT_PUBLIC_REVIEW_ID=$REVIEW_ID NEXT_PUBLIC_BRANCH=$BRANCH pnpm build-docs --filter="docs"' versus '' in the Netlify UI
2:42:05 PM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'node scripts/ignore-build.js'
2:42:05 PM: Changes detected, continuing with build
2:42:05 PM: Starting build script
2:42:05 PM: Installing dependencies
2:42:05 PM: Python version set to 2.7
2:42:06 PM: Started restoring cached node version
2:42:07 PM: Finished restoring cached node version
2:42:07 PM: Downloading and installing node v16.18.0...
2:42:07 PM: Downloading https://nodejs.org/dist/v16.18.0/node-v16.18.0-linux-x64.tar.xz...
2:42:08 PM: Computing checksum with sha256sum
2:42:08 PM: Checksums matched!
2:42:10 PM: Enabling node corepack
2:42:10 PM: Started restoring cached build plugins
2:42:10 PM: Finished restoring cached build plugins
2:42:10 PM: Attempting ruby version 2.7.2, read from environment
2:42:11 PM: Using ruby version 2.7.2
2:42:11 PM: Using PHP version 8.0
2:42:11 PM: No npm workspaces detected
2:42:11 PM: Started restoring cached node modules
2:42:11 PM: Finished restoring cached node modules
2:42:11 PM: Installing NPM modules using NPM version 8.19.2
2:42:13 PM: npm ERR! code EUNSUPPORTEDPROTOCOL
2:42:13 PM: npm ERR! Unsupported URL Type "workspace:": workspace:*
2:42:13 PM: npm ERR! A complete log of this run can be found in:
2:42:13 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-10-20T13_42_12_237Z-debug-0.log
2:42:13 PM: Error during NPM install
2:42:13 PM: Build was terminated: Build script returned non-zero exit code: 1
2:42:13 PM: Creating deploy upload records
2:42:13 PM: Failing build: Failed to build site
2:42:13 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
2:42:13 PM: Finished processing build request in 17.650495802s
@markgaze markgaze added the type: bug code to address defects in shipped code label Oct 20, 2022
@lukasholzer
Copy link
Contributor

Hey yea this can be done currently via setting the environment variable NETLIFY_USE_PNPM=true inside the UI.

We are currently working on auto detecting this case see: netlify/build-image#858 and #4643

@markgaze
Copy link
Author

Hey yea this can be done currently via setting the environment variable NETLIFY_USE_PNPM=true inside the UI.

We are currently working on auto detecting this case see: netlify/build-image#858 and #4643

Great stuff! Thanks for the workaround, I'll give that a go now and keep an eye out for that PR going in 🙂

@markgaze
Copy link
Author

Worked a treat! 😄 Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants