CI breaking yarn workspaces dependency installations

Summary

GitLab.com CI is somehow affecting yarn workspace installation causing workspace modules to not have their dependencies installed.

Steps to reproduce

Create a repo with:

  • a valid package.json specifying workspaces
  • a workspace package.json with a dependency not found in the workspace root
  • a file in the workspace that relies on said dependency
  • a gitlab CI setup that runs:
    • yarn in the root of the workspace
    • runs the aforementioned file

When gitlab CI runs it will fail due to not being able to locate the dependency

When run locally, or in docker, the file executes successfully

Example Project

https://gitlab.com/Normal_Gaussian/bug-repro_yarn-workspace-gitlab--ci

Comparative working examples:

Docker:

sudo docker run -i node bash -c 'git clone https://gitlab.com/Normal_Gaussian/bug-repro_yarn-workspace-gitlab--ci.git && cd bug-repro_yarn-workspace-gitlab--ci && yarn && node index.js && node modules/A/index.js'

Local:

git clone https://gitlab.com/Normal_Gaussian/bug-repro_yarn-workspace-gitlab--ci.git
cd bug-repro_yarn-workspace-gitlab--ci
yarn
node index.js
node modules/A/index.js

What is the current bug behavior?

https://gitlab.com/Normal_Gaussian/bug-repro_yarn-workspace-gitlab--ci/-/jobs/365680975

Here observe that node modules/A/index.js fails with MODULE_NOT_FOUND

147 internal/modules/cjs/loader.js:957
148     throw err;
149     ^
150 Error: Cannot find module '/builds/Normal_Gaussian/bug-repro_yarn-workspace-gitlab--ci/module/A/index.js'
151     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:954:17)
152     at Function.Module._load (internal/modules/cjs/loader.js:847:27)
153     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
154     at internal/main/run_main_module.js:17:47 {
155   code: 'MODULE_NOT_FOUND',
156   requireStack: []
157 }

What is the expected correct behavior?

node modules/A/index.js should output

{ atob: true, btoa: true, usage: '4w==' }

Relevant logs and/or screenshots

https://gitlab.com/Normal_Gaussian/bug-repro_yarn-workspace-gitlab--ci/-/jobs/365680975

Output of checks

This bug happens on GitLab.com

Assignee Loading
Time tracking Loading