activate.fish erases a pre-existing NODE_PATH and never restores it
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 bin/activate.fish 开始,重点关注 deactivate_node 的初始非破坏性处理,以及 NODE_PATH 和两个前缀变量的恢复逻辑。运行 tests/test_activate_shells.py 中受影响的测试,并在该测试对 Fish 通过后移除其 FISH_NODE_PATH_CLOBBER xfail 设置;完成标准是停用后所有原有值都得到恢复。
由索引模型根据 Issue 内容生成。
描述
Summary
Sourcing bin/activate.fish destroys a NODE_PATH the user already had
set. deactivate_node then has nothing to restore, so the variable is gone
for good. NPM_CONFIG_PREFIX and npm_config_prefix have the same defect.
Reproduction
$ nodeenv --prebuilt /tmp/ne
$ fish -c 'set -gx NODE_PATH /my/node_path
source /tmp/ne/bin/activate.fish
deactivate_node
echo "NODE_PATH=[$NODE_PATH]"'
NODE_PATH=[]
Expected NODE_PATH=[/my/node_path], which is what the POSIX bin/activate
does under sh, dash and bash.
Cause
activate.fish calls deactivate_node nondestructive near the top, before
the activation code has saved anything:
# unset irrelevant variables
deactivate_node nondestructive
On that pass _OLD_NODE_PATH is empty, so deactivate_node takes its else
branch and erases the variable:
if test -n "$_OLD_NODE_PATH"
set -gx NODE_PATH $_OLD_NODE_PATH
set -e _OLD_NODE_PATH
else
set -e NODE_PATH
end
The activation code that runs afterwards therefore sees set -q NODE_PATH
as false, never records _OLD_NODE_PATH, and the user's value is lost:
if set -q NODE_PATH
set -gx _OLD_NODE_PATH $NODE_PATH
set -gx NODE_PATH "$NODE_VIRTUAL_ENV/lib/node_modules" $NODE_PATH
else
set -gx NODE_PATH "$NODE_VIRTUAL_ENV/lib/node_modules"
end
b042056 ("fix(nodeenv): guard fish npm config restore") already fixed
exactly this disease, but only for the --isolate-npm variables, by
wrapping the restore in a guard:
# Skip the "deactivate_node nondestructive" pass at the top of
# activate.fish: the variables are only saved after it has run
if set -q NODE_VIRTUAL_ENV
NODE_PATH and the NPM_CONFIG_PREFIX / npm_config_prefix pair never got
that guard.
Scope of the fix
All three variable groups, not just NODE_PATH. The prefix pair is affected
identically; it only looks fine today because the test asserts NODE_PATH
first and stops there.
Test coverage
tests/test_activate_shells.py (added in #397) marks this
xfail(strict=True) as FISH_NODE_PATH_CLOBBER on
test_deactivate_restores_env, via the restoring_shell decorator. When the
fix lands, drop the constant and the decorator and put the test back on
@activating_shell.
- 主要语言
- Python
- 星标
- 1.8k
- 派生
- 224
- 平均合并
- 10 小时 52 分钟
- 30 天内合并 PR
- 23
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ekalinin/nodeenv 的其他 Issue
-
docs
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
docs
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
ekalinin/nodeenv#416 · 3 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
letsencrypt/cp-cps#353 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 84/100
PedestrianDynamics/pyFDS-Evac#394 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
DOI-USGS/pywatershed#421 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
python-pillow/Pillow#10087 · 1 条评论 ·
维护者通常 1 天内回复