Repository navigation
Conversation
ekalinin
left a comment
There was a problem hiding this comment.
Thanks, this fixes #399. Two changes are needed before merge, plus two small ones.
-
[P1] Keep fish replacing NODE_PATH -
nodeenv.py:2227This prepend branch has never run since fish support landed in 2017: the initial
deactivate_node nondestructivepass erasedNODE_PATHfirst, so fish replaced it like the other shells. Now it runs, and modules from the user'sNODE_PATHresolve inside the env, under fish only. Please replace it, as the prefix variables below do:if set -q NODE_PATH set -gx _OLD_NODE_PATH $NODE_PATH end set -gx NODE_PATH "$NODE_VIRTUAL_ENV/__MOD_NAME__"
Then
test_activate_sets_env(tests/test_activate_shells.py:283) can compare the wholeNODE_PATH, not just its first element. -
[P2] Same fix for the --isolate-npm restore -
nodeenv.py:1768It still uses
test -n, so an emptynpm_config_*becomes unset and leaves an exported empty_OLD_npm_config_*behind. Please move__NPM_UNISOLATE__inside the new guard, drop its duplicate guard, switch toset -q, and add the threenpm_config_*names tonamesintest_fish_restores_original_variables. -
[P3] The REQUIRE_SHELLS comment (
tests/test_activate_shells.py:144) still refers to xfail markers, which this PR removes. -
[P3] Please add an
[unreleased]entry for #399 toCHANGES, noting that existing envs need--forceto get the newactivate.fish.
ekalinin
left a comment
There was a problem hiding this comment.
Thanks for the update, all four points from the last round are in. A few more things before merge.
-
Please rebase on master:
CHANGESconflicts with the #419 entry, and CI hasn't run on 306eb92. -
The new
if set -q NODE_VIRTUAL_ENVguard (nodeenv.py:2127) skips the restore whenNODE_VIRTUAL_ENVis already gone:set -gx NODE_PATH /old/np source env/bin/activate.fish set -e NODE_VIRTUAL_ENV deactivate_node
After this,
NODE_PATH,NPM_CONFIG_PREFIXandnpm_config_prefixstill point at the env, sonpm i -gkeeps installing there, and_OLD_NODE_PATH=/old/npstays exported. On master these three are at least erased.activatekeeps all of these restores under one guard,_OLD_NODE_VIRTUAL_PATH, and fish can do the same: move them into the existing PATH block and drop the new guard.if test -n "$_OLD_NODE_VIRTUAL_PATH" set -gx PATH $_OLD_NODE_VIRTUAL_PATH set -e _OLD_NODE_VIRTUAL_PATH # NODE_PATH, NPM_CONFIG_PREFIX and npm_config_prefix restores as now __NPM_UNISOLATE__ end
The nondestructive pass at the top still skips them unless another env is active, because only activation sets
_OLD_NODE_VIRTUAL_PATH. With this change the case above ends withNODE_PATH=/old/np, and the shell tests pass excepttest_isolate_npm_fish_content(tests/test_install_activate.py:411), which looks for theif set -q NODE_VIRTUAL_ENVstring. When you update it, please make its order check fail if__NPM_UNISOLATE__ends up outside the guard. Right now the guard is in everyactivate.fishand always comes first, so the check passes wherever the restores are. -
My
--forcesuggestion forCHANGESwas wrong, sorry. With-p, nodeenv appends the new code to the virtualenv'sactivate.fish, so the old block still runs first and erasesNODE_PATH. Without-p,--forcereinstalls node at the default version and drops--isolate-npmand--promptunless they are passed again. Something like "existing environments keep the oldactivate.fish; recreate them with the same options to get the fix (with-p, remove the old nodeenv part from the virtualenv'sactivate.fishfirst)" would be closer. -
Nit:
assert all(...)attests/test_activate_shells.py:340doesn't say which backup leaked. A dict comparison like the line above it would.
Fish activation currently erases the caller's
NODE_PATH,NPM_CONFIG_PREFIXandnpm_config_prefixbefore saving them. Save their original values and restore them only when leaving an active nodeenv, preserving the distinction between an empty value and an unset variable.While active, replace
NODE_PATHwith the environment's module directory, matching the other shells' isolation behavior. Put the--isolate-npmrestoration under the same active-environment guard, preserve empty cache/userconfig/init-module values, and remove the saved variables after restoring them. Repeated activation and nondestructive deactivation retain the original environment.Behavioral tests now check the entire active
NODE_PATH, all six restored variables, backup cleanup, unset/empty values, multiple paths, spaces and repeated operations, with and without--isolate-npm. The shell-requirement comment is current, andCHANGESnotes that existing environments need--forceto regenerateactivate.fish.Validation on macOS with fish 4.9.3:
22e3d4b: 5 failed, 29 passed. All pass with this correction.NODEENV_REQUIRE_SHELLS=1 python -m pytest tests/test_activate_shells.py: 114 passed on each of Python 3.10.21 and 3.13.12, running sh, dash, bash, zsh and fish.python -m pytest -m 'not integration' tests: 411 passed / 1 failed / 11 skipped on Python 3.10; 412 passed / 1 failed / 10 skipped on Python 3.13; 5 integration cases deselected in each.test_mirror_credentials_stay_out_of_error_messages, which receives HTTP 503 in this local environment. It fails with the same HTTP 503 on unchanged prior head22e3d4bunder both Python versions. With only that confirmed baseline case additionally excluded, the remaining 411 / 412 tests pass.flake8 --extend-ignore=E127 nodeenv.py tests setup.pyandgit diff --check: passed.Older fish releases, other Python versions, Linux/Windows execution and real Node download/build integration are not covered by these local checks. Upstream CI results must be checked against the new head.
Closes #399.