--source: the tmpbin python -> python2 link breaks in several setups
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- build-system
調査の方向性
The bug is in build_node_from_src in nodeenv.py, which looks up python2 and links it as tmpbin/python. Start by running the issue's reproduction script against that function, once per case, to see each failure. Done means the five cases (python2.7 only, dangling link, stale link, pyenv-style shim, relative PATH entry) either build or fail with a clear message, and the fix settles whether the link approach should change.
索引モデルが issue の本文から書いたものです。
説明
On Python 3, build_node_from_src looks up python2 and points python at it through a link in tmpbin (master, ecb4b74):
python2_path = shutil.which('python2')
if not python2_path:
raise OSError(
'Python >=3.0 virtualenv detected, but no python2 '
'command (required for building node.js) was found'
)
logger.debug(' * Temporarily pointing python to %s', python2_path)
node_tmpbin_dir = join(src_dir, 'tmpbin')
node_tmpbin_link = join(node_tmpbin_dir, 'python')
mkdir(node_tmpbin_dir)
if not os.path.exists(node_tmpbin_link):
callit(['ln', '-s', python2_path, node_tmpbin_link])
env['PATH'] = '{}:{}'.format(node_tmpbin_dir,
os.environ.get('PATH', ''))
PR #429 keeps this code for node.js before 13 (the lookup) and before 8.8 (the link). It breaks in these cases:
- Only
python2.7is on PATH. A Python 2.7 installed withmake altinstallhaspython2.7but nopython2. nodeenv raises the "no python2 command" error, although node's own./configurewrapper (6.12+ / 8.5+) triespython2.7first. - A dangling
tmpbin/pythonfrom an earlier run.srcis kept after a failed build or with--no-clean-src, and--forcereuses it.os.path.existsfollows the link, so once the old python2 is gone,ln -sfails withFile exists. - A stale
tmpbin/pythonfrom an earlier run. If the old target still exists, the build uses it instead of the python2 found now. - python2 is a pyenv shim. pyenv shims pick the program by their own name (
program="${0##*/}", thenpyenv exec "$program"), so a link namedpythonto~/.pyenv/shims/python2runspyenv exec python. With e.g.pyenv global 3.12.0 2.7.18that is Python 3.12. - A relative PATH entry.
shutil.whichreturns a relative path (bin/python2), andln -sstores it relative totmpbin/, so the link dangles and./configurecan't findpython.
The link is also made by running ln -s through callit, while the rest of the module uses os.symlink.
Reproduce
On master (ecb4b74) on macOS, where /usr/bin has no python2, with fake scripts in place of node's configure, make and python2. Run from a nodeenv checkout:
T=/tmp/y; mkdir -p $T
git show ecb4b74:nodeenv.py > $T/nodeenv.py
PY=$(command -v python3)
mkscript() { mkdir -p "$(dirname "$1")"; printf '#!/bin/sh\n%s\n' "$2" > "$1"; chmod +x "$1"; }
mkscript $T/tools/make 'exit 0'
mkscript $T/py27/python2.7 'echo "python2.7 runs"'
mkscript $T/py2old/python2 'echo "OLD python2 runs"'
mkscript $T/py2new/python2 'echo "NEW python2 runs"'
mkscript $T/shims/python2 'echo "shim dispatches to: ${0##*/}"'
# every case gets a node source dir whose configure runs `python`
newcase() { mkscript $T/$1/src/node-src/configure 'exec python'; }
cat > $T/run.py <<'EOF'
import sys, types
sys.path.insert(0, '/tmp/y')
import nodeenv
work = sys.argv[1]
args = types.SimpleNamespace(load_average=None, jobs='2', without_ssl=False,
debug=False, profile=False, make_path='/tmp/y/tools/make', verbose=True)
try:
nodeenv.build_node_from_src(work + '/env', work + '/src', work + '/src/node-src', args)
except OSError as e:
print('OSError:', e)
EOF
- Only
python2.7:
newcase c1
env PATH="$T/py27:/usr/bin:/bin" $PY $T/run.py $T/c1
OSError: Python >=3.0 virtualenv detected, but no python2 command (required for building node.js) was found
- Dangling link:
newcase c2; mkdir -p $T/c2/src/tmpbin; ln -s $T/gone/python2 $T/c2/src/tmpbin/python
env PATH="$T/py2new:/usr/bin:/bin" $PY $T/run.py $T/c2
ln: /tmp/y/c2/src/tmpbin/python: File exists
OSError: Command ln -s /tmp/y/py2new/python2 /tmp/y/c2/src/tmpbin/python failed with error code 1
- Stale link:
newcase c3; mkdir -p $T/c3/src/tmpbin; ln -s $T/py2old/python2 $T/c3/src/tmpbin/python
env PATH="$T/py2new:/usr/bin:/bin" $PY $T/run.py $T/c3
OLD python2 runs
- A shim that dispatches on its name like pyenv's:
newcase c4
env PATH="$T/shims:/usr/bin:/bin" $PY $T/run.py $T/c4
shim dispatches to: python
- Relative PATH entry:
newcase c5; mkscript $T/c5/bin/python2 'echo "python2 runs"'
(cd $T/c5 && env PATH="bin:/usr/bin:/bin" $PY $T/run.py $T/c5)
readlink $T/c5/src/tmpbin/python
./configure: line 2: exec: python: not found
OSError: Command ./configure --prefix=/tmp/y/c5/env failed with error code 127
bin/python2
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 225
- 平均マージ
- 17時間 18分
- マージ済み PR(30日)
- 26
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ekalinin/nodeenv のほかの issue
-
README config example breaks when copied into ~/.nodeenvrc対応中かも @jihtsan が 8 日前に担当しました。 オープンdocs
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
activate.fish erases a pre-existing NODE_PATH and never restores it対応中かも @jihtsan が 8 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
メンテナーはふだん 1 日以内に返信
-
--source passes --make, --jobs and --load-average to the shell unquoted対応中かも @jihtsan が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
ekalinin/nodeenv#416 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
ekalinin/nodeenv の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
[Bug]: Queen's own Ollama model loses num_ctx when a running session switches to it対応中かも @anasamin26 が今日担当しました。 オープンbug enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aden-hive/hive#7508 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
llm translation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
BerriAI/litellm#47884 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug 🐛
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
netalertx/NetAlertX#1856 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信