Skip to main content

Module readonly

Module readonly 

Source
Expand description

Package-manager trees mounted read-only for cants that may write the project.

pnpm, Bun and uv (and Yarn with nmMode: hardlinks-*) fill node_modules or .venv with hard links into one store shared by all the user’s projects. Landlock checks the path a file is opened by, not the file, and can’t take files out of a writable directory: a cant that may write the project could change a stored package for every project. So such trees are found with a few stat calls (no walk) and mounted read-only in the cant’s own mount namespace (crate::Plan::readonly); tool caches inside node_modules stay writable.

Constants§

WRITABLE_CACHES
Caches inside node_modules that tools write (eslint, babel, vite, vitest): mounted writable again on top of the read-only tree. .cache is created when missing.

Functions§

not_locked
The warning when the trees can’t be mounted read-only here (no user namespaces).
shared_trees
The package-manager trees under the directories policy lets the cant write: for each writable directory d (from the manifest, the command line or --grant), d/node_modules and d/.venv or d/venv with a pyvenv.cfg, and the same one level down (workspaces). A tree the manifest grants writable itself ($CWD/* grants each entry) is one too. A tree the user named (--grant, or as an argument), or that holds a path they named, is their choice and is left alone. Sorted, distinct.