Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

activate.fish erases a pre-existing NODE_PATH and never restores it

オープン 初心者向け
#399 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
fish, python
領域
tooling

調査の方向性

bin/activate.fish から始め、deactivate_node の初期の非破壊パスと、NODE_PATH および両方の prefix 変数の復元ロジックに焦点を当てます。tests/test_activate_shells.py の対象テストを実行し、Fish でテストが成功したら、その FISH_NODE_PATH_CLOBBER xfail セットアップを削除します。完了の条件は、無効化後に既存の値がすべて復元されることです。

索引モデルが issue の本文から書いたものです。

説明

bug

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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ekalinin/nodeenv のほかの issue

ekalinin/nodeenv の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。