activate.fish erases a pre-existing NODE_PATH and never restores it
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 86/100
調査の方向性
bin/activate.fish から始め、deactivate_node の初期の非破壊パスと、NODE_PATH および両方の prefix 変数の復元ロジックに焦点を当てます。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時間 15分
- マージ済み PR(30日)
- 22
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 25/100
ekalinin/nodeenv#416 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
ekalinin/nodeenv の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
qgis/QGIS-Plugins-Website#459 ·
-
bug severity:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
bot-found bug priority: P3
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
madenvel/KalinkaPlayer#179 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ls1intum/edutelligence#1098 ·
メンテナーはふだん 1 日以内に返信