Repository navigation
fix(nodeenv): do not put the venv bin on PATH twice with -p - #448
Merged
Merged
Conversation
The python venv's own activate and activate.fish put bin/ on PATH, and the part nodeenv -p appends to them added it a second time. That part now adds only node_modules/.bin. A file nodeenv wrote itself (a conda env has none) keeps the entry, so a rerun with other options does not take bin/ off PATH again. Windows keeps it too: before python 3.12 the venv's git-bash activate puts a C:\ path there, which the shell splits at the colon. Fixes #332
ekalinin
added a commit
to jihtsan/nodeenv
that referenced
this pull request
Oct 29, 2026
Resolve the conflicts with ekalinin#439 and ekalinin#448: keep the ekalinin#399 entry above the ekalinin#332 and ekalinin#436 entries in CHANGES, and keep the new python_venv test from ekalinin#448 under @every_shell, since this branch drops @restoring_shell. The earlier merge f506999 cut the "Nodeenv changelog" underline to 10 characters and dropped the blank line after it. docutils reports "Title underline too short" and readme_renderer refuses README.rst + CHANGES, so restore the title as it is on master.
4 of 5 tasks
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.
Fixes #332
What happens
With
nodeenv -p, the python venv's ownbin/activateandbin/activate.fishput$VIRTUAL_ENV/binonPATH, and the part nodeenv appends to them puts$NODE_VIRTUAL_ENV/binthere again. Reproduced on master in sh, dash, bash, zsh and fish. On macOS the two entries are not even the same text:/tmp/x/binfrom python and/private/tmp/x/binfrom nodeenv'scd -P. Deactivation restoresPATHcorrectly, so the duplicate is the whole problem.The patches proposed in the issue were not used: the first one drops
binfor plain (non-p) environments too, and the conditional ones use bash-only[[ ]]and a substring match, which misses the/tmpvs/private/tmpcase.What changes
install_activate()leaves thebinentry out of thePATHline ofactivateandactivate.fishwhen-pappends to a script of the python venv, so that part adds onlynode_modules/.bin.bin/activate, so nodeenv writes it from scratch, and a rerun with other options (--isolate-npm, say) appends to that file: a block withoutbinwould take it offPATHagain throughdeactivate_node nondestructive. Such a file is told apart by its first bytes, which are theDISABLE_PROMPTpart.Scripts/activatesetsVIRTUAL_ENVto aC:\...path, which git-bash splits at the colon, so the venv's own entry only works while the current directory is on the same drive (If the working directory and the venv are on different disks, venv doesn't work in bash on Windows python/cpython#103088).activate.batandActivate.ps1never had the duplicate.nodeenv -pagain on an already affected venv fixes it: the new block is appended and resetsPATHbefore addingnode_modules/.bin.Tests
The new tests fail on master and pass with the fix:
test_python_virtualenv_puts_bin_on_path_onceintest_activate_shells.pycreates a real venv withpython -m venv, appends the-ppart and checks the wholePATHin every shell;test_python_virtualenv_puts_bin_on_path_onceintest_install_activate.pychecks the generatedPATHlines, andtest_python_virtualenvexpects the shorter line;test_win_python_virtualenv_appends_to_activatechecks that the git-bashactivatekeepsScripts.test_python_virtualenv_rerun_leaves_activate_aloneandtest_python_virtualenv_own_activate_keeps_binpass on master. They guard the reruns: the second one fails ifbinis dropped whenever the file already exists.