Skip to content

fix(link-bins,headless): scope GVS read-only error suppression - #11017

Closed
vsumner wants to merge 1 commit into
pnpm:mainfrom
vsumner:fix/readonly-gvs-on-alpha16
Closed

vsumner wants to merge 1 commit into
pnpm:mainfrom
vsumner:fix/readonly-gvs-on-alpha16

Conversation

@vsumner

@vsumner vsumner commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Context

Part of the ongoing work to make the Global Virtual Store (GVS) work with read-only content-addressable stores (e.g. Nix). When enableGlobalVirtualStore is active and the store is read-only, post-import linking operations (symlinkDependency for self-deps, fs.mkdir for bin directories) fail with EACCES/EROFS/EPERM because the target lives inside an immutable store path.

This PR suppresses those errors for GVS installs only, so non-GVS installs still get clear errors on genuine permission problems.

Follows #10965 (virtualStoreOnly), #10709 (GVS warm reattach), #10836 (CI GVS config).

What changed

@pnpm/link-bins

  • Add allowReadonlyErrors?: boolean to LinkBinOptions
  • _linkBins only suppresses mkdir errors when the flag is set
  • Extract isReadonlyError() helper using util.types.isNativeError() (per codebase convention, matching read-projects-context and plugin-commands-installation)

@pnpm/headless

  • Thread enableGlobalVirtualStore through linkAllBins → all three linkBins/linkBinsOfPackages call sites as allowReadonlyErrors
  • Guard the self-dep symlink catch with if (opts.enableGlobalVirtualStore); non-GVS path has no try/catch overhead
  • Use util.types.isNativeError() instead of duck-typing

Tests (3 new in @pnpm/link-bins)

  • EACCES + allowReadonlyErrors: true → returns [] (suppressed)
  • EACCES + no flag → throws (not suppressed)
  • ENOTDIR + allowReadonlyErrors: true → throws (non-readonly errors always re-thrown)

Verification

  • pnpm --filter @pnpm/link-bins test: 36/36 pass
  • pnpm --filter @pnpm/headless compile: clean (1 pre-existing lint warning)
  • Pre-push hooks (spellcheck, meta-updater, eslint): all pass

@vsumner
vsumner requested a review from zkochan as a code owner March 18, 2026 21:09
Copilot AI review requested due to automatic review settings March 18, 2026 21:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR scopes “read-only filesystem” error suppression (EACCES/EROFS/EPERM) to Global Virtual Store (GVS) code paths so that non-GVS installs correctly surface real permission problems during bin linking and self-dependency symlinking.

Changes:

  • Add an allowReadonlyErrors option to @pnpm/link-bins and gate readonly error suppression on it.
  • Thread enableGlobalVirtualStore through @pnpm/headless bin-linking and self-dep symlinking paths to control suppression.
  • Add targeted tests in @pnpm/link-bins plus a changeset for patch releases.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg-manager/link-bins/test/index.ts Adds tests covering readonly suppression vs passthrough vs non-readonly rethrow.
pkg-manager/link-bins/src/index.ts Introduces allowReadonlyErrors and readonly error detection; gates suppression.
pkg-manager/headless/src/index.ts Threads enableGlobalVirtualStore to bin linking and guards self-dep symlink suppression.
.changeset/fix-gvs-readonly-error-handling.md Declares patch releases and documents the behavioral change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread bins/linker/src/index.ts Resolved
Comment thread bins/linker/src/index.ts Resolved
@vsumner
vsumner force-pushed the fix/readonly-gvs-on-alpha16 branch from bf92938 to 095b9a5 Compare March 18, 2026 21:17
Narrow EACCES/EROFS/EPERM suppression to Global Virtual Store
codepaths only, so non-GVS installs still throw on permission
errors instead of silently skipping bin linking and self-dep
symlinking.

- Add allowReadonlyErrors flag to LinkBinOptions
- Thread enableGlobalVirtualStore through linkAllBins
- Use util.types.isNativeError() per codebase convention
- Add tests for suppression, passthrough, and re-throw
@vsumner
vsumner force-pushed the fix/readonly-gvs-on-alpha16 branch from 095b9a5 to 8b5a284 Compare March 18, 2026 21:18
@zkochan

zkochan commented Mar 18, 2026

Copy link
Copy Markdown
Member

I don't understand. There are many fs operations during install. Why only these fail and all others work?

@vsumner

vsumner commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

Good question. In GVS mode, most fs operations succeed because they either target the project's local node_modules (which is writable) or use storeController.importPackage with safeToSkip: true, which skips the import entirely when the package already exists in the store.

The two operations that fail are the ones that write into the already-imported package directory (depNode.dir), which in a read-only store (e.g. Nix) is immutable:

  1. Self-dep symlinking — creates a symlink at <depNode.dir>/node_modules/<name>, which means writing inside the package directory
  2. Bin linking — runs fs.mkdir(<depNode.dir>/node_modules/.bin) to create the bin directory inside the package

Everything else either writes to the project-local node_modules tree or skips when the store is warm. These two are the only post-import operations that try to mutate the package directory itself.

@vsumner

vsumner commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by a better approach: skip post-import linking entirely for warm GVS packages instead of catching read-only errors.

@vsumner

vsumner commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

@zkochan this treats the problem instead of the sympton like this pr does #11020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants