feat(nodeenv): clean "src" directory by default - #404
Merged
Merged
Conversation
A prebuilt install leaves a full copy of node under <env>/src, so an environment is twice the size it needs to be: 441M instead of 221M for node 26.9.0. Nothing reads that copy back. The "already downloaded" check looks for src/node-v<ver>, while a prebuilt archive unpacks into src/node-v<ver>-<platform>, so in the default mode the directory is not even a download cache. Flip --clean-src on by default and add --no-clean-src for the case that does benefit from keeping it: with --source the directory holds the source tree a repeated --force build reuses. --clean-src and -c keep working, pre-commit passes the flag explicitly. clean_src also becomes a Config attribute, so it can now be set in tox.ini, setup.cfg or ~/.nodeenvrc. Closes #205
ekalinin
force-pushed
the
feat/clean-src-by-default
branch
from
September 20, 2026 11:59
c39b05d to
4cd4d9d
Compare
This was referenced Sep 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #205.
Problem
A prebuilt install leaves a full copy of node under
<env>/src, so an environment is twice the size it needs to be. Measured on macOS arm64 with node 26.9.0:Nothing reads that copy back. The "already downloaded" check looks for
src/node-v<ver>, while a prebuilt archive unpacks intosrc/node-v<ver>-<platform>, so in the default mode the directory is not even a download cache - the tarball is downloaded again on every run.Two smaller facts from the same path:
clean_srcwas not aConfigattribute, so it could not be set in a config file at all, and-n systemcreatedsrcunconditionally and left it empty.Change
--clean-srcis now the default, and--no-clean-srcopts out.Keeping
srcis worth it in exactly one case: with--sourcethe directory holds the source tree that a repeated--forcebuild reuses. That case now needs--no-clean-src, which is noted inCHANGES. A default that differs per install mode would be invisible from--help, so both modes clean by default.--clean-srcand-ckeep working. pre-commit passes the flag explicitly (['-mnodeenv', '--prebuilt', '--clean-src', envdir]), and a test asserts it still parses.clean_srcalso becomes aConfigattribute, so it can be set intox.ini,setup.cfgor~/.nodeenvrc:mkdir(src_dir)stays unconditional: the emptysrcfrom-n systemis now removed by the default cleanup, and it survives only under an explicit--no-clean-src, which is what that flag asks for.Verified
srcafter the runnodeenv --prebuilt ne1nodeenv --prebuilt --no-clean-src ne2nodeenv -n system ne3clean_src = falsein a config filenodeenv -n system -c ne5235 tests pass (233 unit plus the 2 integration smoke tests),
flake8 --extend-ignore=E127 nodeenv.py tests setup.pyis clean.Out of scope
A shared download cache outside the environment, which would fix the repeated downloads that prebuilt mode does today. That also makes the dead
node_src_dircheck meaningful again, and both belong together in a separate change.