Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,21 @@ jobs:
# tracked changes) — without it, a duplicate user-agent line lands on master every
# release and, being last in the file, overrides bit-repo-local for local installs too.
# the flag lives in .git/index, so it survives persist_to_workspace into later jobs.
#
# storeDir moves the store — and with it the global virtual store at <storeDir>/<version>/links,
# which every node_modules entry symlinks into — under the persist_to_workspace root, so the
# later jobs that only attach the workspace get resolvable symlinks. pnpm's default store
# lives in ~/.local/share/pnpm, outside that root. it has to go in pnpm-workspace.yaml:
# .npmrc only carries npm-compatible settings, and store-dir there is silently ignored by
# the config reader bit installs through (see scopes/dependencies/pnpm/read-config.ts).
# the repo has no committed pnpm-workspace.yaml; info/exclude keeps this CI-only one from
# being picked up by anything that stages untracked files.
command: >
cd bit &&
echo "user-agent=bit-repo-circleci" >> .npmrc &&
git update-index --skip-worktree .npmrc &&
echo "storeDir: /home/circleci/bit/.pnpm-store" > pnpm-workspace.yaml &&
echo "pnpm-workspace.yaml" >> .git/info/exclude &&
Comment on lines +678 to +679

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informational

1. Hard-coded storedir path 🐞 Bug ⚙ Maintainability

CircleCI hard-codes the pnpm store location to /home/circleci/bit/.pnpm-store, coupling the
install output to the current executor user/home + working_directory layout. If the executor
image/user or working_directory ever changes, the global virtual store can end up outside the
persisted workspace root and downstream jobs may get dangling node_modules symlinks.
Agent Prompt
### Issue description
The CircleCI setup writes `pnpm-workspace.yaml` with an absolute `storeDir` under `/home/circleci/bit`, which is brittle if the job’s working directory or executor home ever changes.

### Issue Context
- The job working directory is configured as `~/bit`.
- `storeDir` and its verification step repeat `/home/circleci/bit` explicitly.

### Fix Focus Areas
- .circleci/config.yml[15-20]
- .circleci/config.yml[674-702]

### Suggested fix
In the `bbit install` step, compute the store path from the actual runtime directory (e.g., the outer workspace root) and use that variable consistently for:
- the `storeDir:` written into `pnpm-workspace.yaml`
- the verification step

For example, set `STORE_DIR="$(cd .. && pwd)/.pnpm-store"` (or similar, depending on where you want the store relative to the persisted root) and write `storeDir: ${STORE_DIR}`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

bbit install
# `bbit install` compiles as part of the install, but that pass can fall back to the
# default TypeScript compiler for components whose env is still being imported - notably
Expand All @@ -679,11 +690,24 @@ jobs:
# - run: cd bit && ls -l node_modules/@babel
# - run: cd bit && ls -l node_modules/@babel/cli/bin
# - run: cd bit && ls -l node_modules/.bin
- run:
# a persist path that matches nothing is not an error, so without this check a store that
# landed outside the workspace root only shows up much later, as a MODULE_NOT_FOUND on a
# dangling node_modules symlink in whichever job runs first.
name: verify the global virtual store sits inside the persisted workspace
command: |
set -e
ls -d /home/circleci/bit/.pnpm-store/*/links
ls -l bit/node_modules/oxlint
test -e bit/node_modules/oxlint/bin/oxlint
- persist_to_workspace:
root: .
paths:
- bit
- .pnpm-store
# only the global virtual store, not the content-addressable files/ it hardlinks from:
# the consumers of this workspace read node_modules, they never fetch packages, and
# carrying files/ too would duplicate every package in the archive.
- .pnpm-store/*/links
Comment on lines +707 to +710

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Persisted links path mismatch 🐞 Bug ☼ Reliability

The CircleCI workspace persists .pnpm-store/*/links, but Bit resolves the global virtual store at
<storeDir>/links; if the resolved storeDir is /home/circleci/bit/.pnpm-store (as configured),
downstream jobs that only attach the workspace may miss the actual links directory and end up with
broken node_modules symlinks.
Agent Prompt
## Issue description
CircleCI persists `.pnpm-store/*/links`, but Bit/pnpm’s global virtual store directory is computed as `<storeDir>/links`. If pnpm resolves `storeDir` to the configured `/home/circleci/bit/.pnpm-store`, the actual required directory would be `.pnpm-store/links`, which is not matched by `.pnpm-store/*/links`.

This can break downstream jobs that rely on the attached workspace (without reinstalling) because `node_modules` entries may symlink into the missing global virtual store.

## Issue Context
- CI explicitly sets `store-dir=/home/circleci/bit/.pnpm-store`.
- Bit’s pnpm adapter computes the global virtual store as `join(config.storeDir, 'links')`.
- Downstream jobs (e.g. `lint`) attach the workspace and run commands without reinstalling.

## Fix Focus Areas
- .circleci/config.yml[665-710]

## Suggested fix
Update `persist_to_workspace.paths` to persist the exact `links` directory that Bit/pnpm uses.

A pragmatic, layout-tolerant option that still avoids persisting `files/` is to include both possible layouts:
- `.pnpm-store/links`
- `.pnpm-store/*/links`

(If you want to be stricter/cleaner, ensure the persisted path exactly matches the resolved `<storeDir>/links` layout you expect in CI.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

- store_artifacts:
path: ~/Library/Caches/Bit/logs
- store_artifacts:
Expand Down
2 changes: 1 addition & 1 deletion mocha-multi-reporters-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"reporterEnabled": "spec, mocha-junit-reporter",
"reporterEnabled": "spec, ./node_modules/mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "${MOCHA_FILE}",
"outputs": "true"
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"lint-full": "./scripts/validate-import-named-aspects.sh && ./scripts/validate-no-ramda.sh && node scripts/validate-pkg-exist-in-pkg-json.js && npm run lint",
"format": "prettier \"{e2e,scopes,components}/**/*.{ts,js,jsx,css,scss,tsx,md,mdx}\" --write",
"prettier:check": "prettier --list-different \"{e2e,scopes,components}/**/*.{ts,js,jsx,css,scss,tsx,md,mdx}\"",
"mocha-circleci": "cross-env NODE_OPTIONS='--no-warnings --max-old-space-size=5000' registry-mock prepare && mocha --require ./babel-register --reporter mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors --exit",
"mocha-circleci": "cross-env NODE_OPTIONS='--no-warnings --max-old-space-size=5000' registry-mock prepare && mocha --require ./babel-register --reporter ./node_modules/mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors --exit",
"e2e-test": "registry-mock prepare && cross-env NODE_OPTIONS=--no-warnings mocha --require ./babel-register './e2e/**/*.e2e*.ts'",
"e2e-test:debug": "npm run e2e-test --debug",
"e2e-test-circle": "cross-env NODE_OPTIONS='--no-warnings --max-old-space-size=5000' mocha --require ./babel-register --reporter mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors --exit './e2e/**/*.e2e*.ts'",
"e2e-test-circle": "cross-env NODE_OPTIONS='--no-warnings --max-old-space-size=5000' mocha --require ./babel-register --reporter ./node_modules/mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors --exit './e2e/**/*.e2e*.ts'",
"performance-test": "mocha --require ./babel-register ./e2e/performance/*.performance*.ts",
"performance-test:debug": "npm run performance-test --debug",
"performance-test-circle": "mocha --require ./babel-register --reporter mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors ./e2e/performance/*.performance*.ts",
"bit-hub-test-circle": "mocha --require ./babel-register --reporter mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors ./e2e/bit-hub/*.ts",
"performance-test-circle": "mocha --require ./babel-register --reporter ./node_modules/mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors ./e2e/performance/*.performance*.ts",
"bit-hub-test-circle": "mocha --require ./babel-register --reporter ./node_modules/mocha-multi-reporters --reporter-options configFile=mocha-multi-reporters-config.json --colors ./e2e/bit-hub/*.ts",
"clean-node-modules": "find . -type d -name node_modules -prune -exec rm -rf '{}' +",
"setup": "bit install && bit compile",
"full-setup": "rm -rf node_modules/.bin/bit && bit install && husky && bit compile",
Expand Down
1 change: 1 addition & 0 deletions workspace.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"resolveEnvsFromRoots": true
},
"teambit.dependencies/dependency-resolver": {
"enableGlobalVirtualStore": true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Prune deletes pnpm internals 🐞 Bug ☼ Reliability

With enableGlobalVirtualStore enabled, pnpm keeps pnpm-owned dot entries under
node_modules/.pnpm, but pnpmPruneModules() does not exclude dot entries and will remove them
when they don’t appear in the lockfile’s package list. This can break or destabilize subsequent
installs by deleting pnpm-managed virtual-store state (or forcing it to be recreated unpredictably).
Agent Prompt
### Issue description
After this PR enables `enableGlobalVirtualStore` in `workspace.jsonc`, installs run in the global virtual store layout where `node_modules/.pnpm` contains pnpm-owned entries (including dot-prefixed directories). The post-install prune step (`pnpmPruneModules`) currently treats *all* entries except `lock.yaml` and `node_modules` as prune candidates, so it may delete pnpm-owned dot entries.

### Issue Context
- The workspace runs a prune step after installs.
- Repo e2e/helper code explicitly treats dot entries under `node_modules/.pnpm` as pnpm-owned internals that should not be considered dependency directories.

### Fix Focus Areas
- scopes/dependencies/pnpm/pnpm-prune-modules.ts[21-50]

### Suggested fix
- Change `readPackageDirsFromVirtualStore()` to:
  - use `readdir(..., { withFileTypes: true })`
  - include **directories only**
  - exclude entries that start with `.`
  - keep excluding `node_modules` and `lock.yaml`
- Add/adjust an e2e or unit test for the global virtual store path to ensure prune does not remove dot-prefixed pnpm entries under `node_modules/.pnpm`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Schema missing gvs key 🐞 Bug ⚙ Maintainability

workspace.jsonc now sets enableGlobalVirtualStore, but the repo’s workspace-jsonc-schema.json
does not define this property under teambit.dependencies/dependency-resolver, so schema-driven
validation/autocomplete cannot surface/validate the new config key.
Agent Prompt
### Issue description
`workspace.jsonc` enables `enableGlobalVirtualStore`, but `workspace-jsonc-schema.json` does not declare this option in the `teambit.dependencies/dependency-resolver` schema. This creates schema/config drift: editors and any schema validation tooling won’t recognize the new key.

### Issue Context
The config key is a real, supported option in code (`DependencyResolverWorkspaceConfig.enableGlobalVirtualStore?: boolean`), so the schema should be updated to match.

### Fix Focus Areas
- workspace-jsonc-schema.json[51-320]
- workspace.jsonc[13-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

"allowScripts": {
"@apollo/protobufjs": true,
"@parcel/watcher": true,
Expand Down