thisroot.sh: wrong ROOTSYS in zsh when the shell's command line has a newline
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 86/100
調査の方向性
config/thisroot.shを読み、getTrueShellExeNameと、その結果がシェル固有の分岐をどのように選択するかに注目してください。issueにある複数行のzsh -f -cコマンドで再現し、コマンド引数に改行が含まれる場合でも、提案された最初の引数の抽出が機能することを確認してください。このzshの場合にROOTSYSとPYTHONPATHが正しく設定されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Check duplicate issues.
- Checked for duplicates
Description
thisroot.sh fails in zsh when the shell was started with a command of more than one line (zsh -c with a newline in its argument, as tools that run shell commands for you often do, e.g. with a heredoc). It prints ERROR: root-config not found under ROOTSYS="..." and leaves ROOTSYS and PYTHONPATH unset, so PyROOT can't be imported.
The cause is getTrueShellExeName, which reads the shell's name with
trueExe=$(cut -d '' -f1 /proc/$$/cmdline 2>/dev/null)
cut works line by line, so when an argument of the command line contains newlines, it prints the first field of every line: zsh, then the first word of each later line. The name no longer equals zsh, so the script takes its dash/ksh branch (lsof), gets the wrong SOURCE, and computes a wrong ROOTSYS. bash goes through the same garbled name (which: no bash ..., basename: missing operand, WARNING: shell name was not found. Assuming 'bash'.), but its fallback happens to be right.
The line is unchanged on master (config/thisroot.sh).
A fix that takes only the first argument whatever it contains:
trueExe=$(tr '\0' '\n' < /proc/$$/cmdline | head -n 1)
Reproducer
# one line: works
zsh -f -c 'source /path/to/root/bin/thisroot.sh; echo "ROOTSYS=$ROOTSYS"'
# ROOTSYS=/path/to/root
# the same with a second line: fails
zsh -f -c 'source /path/to/root/bin/thisroot.sh; echo "ROOTSYS=$ROOTSYS"
true'
# ERROR: root-config not found under ROOTSYS="/home/user/code/"
# ROOTSYS=
# what thisroot.sh reads as the shell's name
zsh -f -c 'cut -d "" -f1 /proc/$$/cmdline
: second line'
# zsh
# : second line
ROOT version
6.40.02 (6-40-02), linuxx8664gcc
Installation method
Built from source; sourced through bin/thisroot.sh
Operating system
CentOS Stream 10 under WSL2, zsh 5.9
Additional context
Found because every shell an AI coding agent started with a multi-line command lacked ROOT's environment, so PyROOT scripts failed only when the command spanned several lines.
- 主要言語
- C++
- スター
- 3.3k
- フォーク
- 1.6k
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 197
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
root-project/root のほかの issue
-
[tmva][sofie] Inputs of unsupported type (e.g. float16) give code that does not compile instead of an error対応中かも @lmoneta が 11 日前に担当しました。 オープンAI-Assisted bug in:SOFIE
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
root-project/root#23655 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
`TChain::GetEntries` internal caching ineffective?対応中かも @pcanal が 4 日前に担当しました。 オープンimprovement in:TTree
root-project/root#23738 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[tmva][sofie] Selu ignores its alpha and gamma attributes対応中かも @lmoneta が 3 日前に担当しました。 オープンbug in:SOFIE
root-project/root#23734 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[PyROOT] Segfault at exit deleting a branch with a Cling-generated collection destructor after cppyy instantiated a template対応中かも @guitargeek が 4 日前に担当しました。 オープンbug in:Python Interface
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
root-project/root#23728 · コメント 8 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Potential problems on Windows due to conflicting CRT libraries対応中かも @bellenot が 6 日前に担当しました。 オープンimprovement in:Core Libraries
root-project/root#23713 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
root-project/root の issue をすべて見る
似ている issue
-
P2: A timed rotation maneuver does nothing on a ship that had an earlier timed lateral maneuverオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
scp-fs2open/fs2open.github.com#7914 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
eclipse-score/inc_someip_gateway#356 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
HarperFast/rocksdb-js#945 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信