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

thisroot.sh: wrong ROOTSYS in zsh when the shell's command line has a newline

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

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

@dpiparo がすでに取り組んでいます。

2026年10月19日 から。

  • #23747 @jinchuntan による — オープン

評価

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

調査の方向性

config/thisroot.shを読み、getTrueShellExeNameと、その結果がシェル固有の分岐をどのように選択するかに注目してください。issueにある複数行のzsh -f -cコマンドで再現し、コマンド引数に改行が含まれる場合でも、提案された最初の引数の抽出が機能することを確認してください。このzshの場合にROOTSYSとPYTHONPATHが正しく設定されれば完了です。

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

説明

bug in:Build System
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

環境構築

はじめの一歩

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

root-project/root のほかの issue

root-project/root の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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