3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Github Actionsでwhichコマンド実行したらジョブが終了する

3
Last updated at Posted at 2026-09-13

はじめに

  • 低レイヤーをあまり知らないが、dockerのマルチステージビルドを雰囲気でしたことはある

問題

  • Github Actionsで使えないコマンドがあってwhichで調査するも思った挙動でなかった

解決

  • コマンドがない時にジョブ終了せず、明示的に何が起きたか出したかったので以下のように定義した
      - name: Debug Firebase Path
        run: which firebase || echo 'firebase not found'

終わりに

  • 色々調べたことを書く

パッケージ確認

  • Github Actions上でwhichコマンド実行してコマンドがなかったら、そこでジョブが止まってしまった
  • なのでそのパッケージのwhichの挙動を調べるために以下を実行した
  • 結果からdebian系と確認
      - name: Debug Which Command
        run: |
          type -p which
          
          # 1. リンク先の実体パスを確認
          readlink -f $(type -p which)

          # 2. 実体パスからパッケージを逆引き
          dpkg -S $(readlink -f $(type -p which))

ドキュメントを読む

  • ドキュメント によるとコマンドない時は1が返ってくるので落ちるようだ
  • 対策として以下のようにした。こうすることでジョブが終わらないかつ、明示的に何が起きたかを表示できる
      - name: Debug Firebase Path
        run: which firebase || echo 'firebase not found'

ローカルのmacのzshについても確認

hoge: command not found
  • ではローカルmacのzshではなぜ上記になるのかと調べた
  • command not found の挙動は終了ステータス127として定義されているようだ

3
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?