Error when building with Yarn 2: Internal Error: Workspace not found

I have recently switched to using yarn2 for my project and I’m facing the following build problem (happens during yarn install). doing Yarn install works locally

9:27:23 PM: Build ready to start
9:27:25 PM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
9:27:25 PM: build-image tag: v3.7.0
9:27:25 PM: buildbot version: 68839536b64446440278e07b38fcad98216e3497
9:27:26 PM: Fetching cached dependencies
9:27:26 PM: Starting to download cache of 323.3MB
9:27:38 PM: Finished downloading cache in 12.082623751s
9:27:38 PM: Starting to extract cache
9:27:54 PM: Finished extracting cache in 16.020437877s
9:27:54 PM: Finished fetching cache in 28.434891886s
9:27:54 PM: Starting to prepare the repo for build
9:27:55 PM: Preparing Git Reference refs/heads/master
9:28:09 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
9:28:10 PM: Starting build script
9:28:10 PM: Installing dependencies
9:28:10 PM: Python version set to 2.7
9:28:11 PM: Started restoring cached node version
9:28:14 PM: Finished restoring cached node version
9:28:15 PM: Downloading and installing node v15.11.0...
9:28:16 PM: Downloading https://nodejs.org/dist/v15.11.0/node-v15.11.0-linux-x64.tar.xz...
9:28:16 PM: Computing checksum with sha256sum
9:28:16 PM: Checksums matched!
9:28:21 PM: Now using node v15.11.0 (npm v7.6.0)
9:28:21 PM: Started restoring cached build plugins
9:28:21 PM: Finished restoring cached build plugins
9:28:21 PM: Attempting ruby version 2.7.1, read from environment
9:28:23 PM: Using ruby version 2.7.1
9:28:24 PM: Using PHP version 5.6
9:28:24 PM: Started restoring cached yarn cache
9:28:24 PM: Finished restoring cached yarn cache
9:28:26 PM: Found yarn version (2.4.1) that doesn't match expected (1.22.4)
9:28:26 PM: up to date, audited 1 package in 311ms
9:28:26 PM: found 0 vulnerabilities
9:28:26 PM: Installing yarn at version 1.22.4
9:28:26 PM: Installing Yarn!
9:28:26 PM: > Downloading tarball...
9:28:26 PM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.Ru75UDi4P4
9:28:26 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
9:28:26 PM:                                  Dload  Upload   Total   Spent    Left  Speed
9:28:26 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
9:28:26 PM: 100    79  100    79    0     0    282      0 --:--:-- --:--:-- --:--:--   283
9:28:26 PM: 100    93  100    93    0     0    173      0 --:--:-- --:--:-- --:--:--   173
9:28:27 PM: 100   625  100   625    0     0    743      0 --:--:-- --:--:-- --:--:--   743
9:28:27 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
9:28:27 PM: 100 1215k  100 1215k    0     0   889k      0  0:00:01  0:00:01 --:--:-- 2333k
9:28:27 PM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.Ru75UDi4P4.asc
9:28:27 PM: 100    83  100    83    0     0   1925      0 --:--:-- --:--:-- --:--:--  1925
9:28:27 PM: 100    97  100    97    0     0   1356      0 --:--:-- --:--:-- --:--:--  1356
9:28:27 PM: 100   629  100   629    0     0   6372      0 --:--:-- --:--:-- --:--:--  6372
9:28:27 PM: 100  1028  100  1028    0     0   7026      0 --:--:-- --:--:-- --:--:--  7026
9:28:27 PM: > Verifying integrity...
9:28:27 PM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
9:28:27 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
9:28:27 PM: gpg: WARNING: This key is not certified with a trusted signature!
9:28:27 PM: gpg:          There is no indication that the signature belongs to the owner.
9:28:27 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
9:28:27 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
9:28:27 PM: > GPG signature looks good
9:28:27 PM: > Extracting to ~/.yarn...
9:28:28 PM: > Adding to $PATH...
9:28:28 PM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
9:28:28 PM: Started restoring cached node modules
9:28:28 PM: Finished restoring cached node modules
9:28:29 PM: Installing NPM modules using Yarn version 2.4.1
9:28:30 PM: ➤ YN0050: The cache-folder option has been deprecated; use rc settings instead
9:28:30 PM: Internal Error: Workspace not found (/)
9:28:30 PM:     at ie.getWorkspaceByCwd (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:354146)
9:28:30 PM:     at ie.get topLevelWorkspace [as topLevelWorkspace] (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:353891)
9:28:30 PM:     at T (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:279347)
9:28:30 PM:     at te.findPackageLocator (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:266710)
9:28:30 PM:     at ie.findLocatorForLocation (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:356963)
9:28:30 PM:     at async Function.find (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:350480)
9:28:30 PM:     at async de.execute (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:76746)
9:28:30 PM:     at async de.validateAndExecute (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:2:660570)
9:28:30 PM:     at async Y.run (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:17:3854)
9:28:30 PM:     at async Y.runExit (/opt/build/repo/.yarn/releases/yarn-2.4.1.cjs:17:4021)
9:28:30 PM: Error during Yarn install
9:28:30 PM: Build was terminated: Build script returned non-zero exit code: 1
9:28:30 PM: Failing build: Failed to build site
9:28:30 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
9:28:30 PM: Finished processing build request in 1m4.909626445s

Site name: determined-haibt-ab63ba
build settings: image

Hey there, @stvad

Sorry for the slow response time! Thanks for reaching out. I know it has been a few days since you posted this-- are you still encountering the same issue? If you are, can you share what you have tried between posting this and now?

Hey Hillary,

Just tried it and it still happens :frowning:. I’ve been doing manual builds & uploads for the time being =\

This is the thing I see that is most concerning:

Do you see that we’ve got 2 VERY different versions of yarn going there? Could you try explicitly setting a $YARN_VERSION as well to make sure that the ONLY version we use, is the version you intend? Pretty sure workspaces weren’t a thing with v1.22 (or anyway, they have improved since), so I assume you use a much newer version locally?

If you can get to just one yarn version in the build logs, I think we’ll be debugging something more straightforward :slight_smile:

I think this is just how Yarn 2 works: https://yarnpkg.com/getting-started/install
you install binary for v1 and if project is configured appropriately - it’d run v2 (which is recommended to be commited directly into the repo )

question - have you tried getting our build image to run locally? that might provide some useful information: