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

Git hooks spam ImageMagick 'import' usage on every commit (pipx polyglot shebang misdetected as interpreter)

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

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

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

評価

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

調査の方向性

GRAPHIFY_PYTHON プローブを含む post-commit および post-checkout フックのテンプレートまたは生成コードから始め、続いて両方のコピーを比較します。ImageMagick の import コマンドがある環境で、インストール済みのフックに対して sh -x を使用して再現し、フックのインストール後に commit または checkout を実行しても usage ダンプが生成されず、グラフは引き続き再構築されることを確認します。

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

説明

Summary

The installed post-commit / post-checkout git hooks print ImageMagick's import usage dump on every commit and checkout when the graphify launcher uses a #!/bin/sh polyglot shebang (the pipx-installed layout). The graph still rebuilds correctly via the python3 fallback, so it's cosmetic — but it spams several dozen lines of Usage: import [options ...] into the output of every git commit.

Environment

  • graphify (pip package graphifyy) 0.4.12, installed via pipx
  • macOS (Apple Silicon), Homebrew ImageMagick present on PATH (provides a binary named import)

Root cause

The pipx launcher ~/.local/bin/graphify starts with a polyglot shebang that re-execs into the venv Python:

#!/bin/sh
'''exec' "/…/pipx/venvs/graphifyy/bin/python" "$0" "$@"
' '''
import sys
from graphify.__main__ import main

The hook detects the interpreter by reading the launcher's first line:

_SHEBANG=$(head -1 "$GRAPHIFY_BIN" | sed 's/^#![[:space:]]*//')

For this launcher that yields GRAPHIFY_PYTHON=/bin/sh. The hook then validates it with:

if [ -n "$GRAPHIFY_PYTHON" ] && ! "$GRAPHIFY_PYTHON" -c "import graphify" 2>/dev/null; then

which runs /bin/sh -c "import graphify". On any machine with ImageMagick on PATH, import is ImageMagick's screen-capture tool, so it prints its full usage text to stdout (the probe only redirects stderr). The check's exit code still works, so GRAPHIFY_PYTHON is reset and the python3 fallback runs — the graph rebuilds fine, but the usage dump already leaked to the terminal.

sh -x .git/hooks/post-commit trace:

+ GRAPHIFY_PYTHON=/bin/sh
+ /bin/sh -c 'import graphify'
Usage: import [options ...] [ file ]
...
+ GRAPHIFY_PYTHON=
+ python3 -c 'import graphify'   # fallback, works

Suggested fixes (either/both)

  1. Silence the probe's stdout too — it's only used for its exit status:

    ! "$GRAPHIFY_PYTHON" -c "import graphify" >/dev/null 2>&1
    

    (applies to the same probe in both post-commit and post-checkout)

  2. Don't trust a /bin/sh shebang as the interpreter — the launcher is a polyglot; reject shebangs whose basename isn't a python* before probing (or just skip straight to the python3/python fallback when it isn't).

Fix #1 alone removes the noise for any stray interpreter guess; #2 addresses the misdetection at its source.

Workaround

Add >/dev/null 2>&1 to the probe line in the installed .git/hooks/post-commit and .git/hooks/post-checkout, but graphify hook install regenerates them and reintroduces the noise.

主要言語
Python
スター
124k
フォーク
11.9k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

Graphify-Labs/graphify のほかの issue

Graphify-Labs/graphify の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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