composer install 時のエラー

  • 経緯
    • ざっくり言うと、PHP公式 Docker の 7.1-fpm をベースに composer を追加した Docker イメージを作成していた
    • その際、composer install 時のエラーでハマったので備忘録
# composer install --dev
Do not run Composer as root/super user! See https://getcomposer.org/root for details
You are using the deprecated option "dev". Dev packages are installed by default now.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 84 installs, 0 updates, 0 removals
    Failed to download aura/installer-default from dist: The zip extension and unzip command are both missing, skipping.
Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
    Now trying to download from source
  - Installing aura/installer-default (1.0.0): Cloning 52f8de3670

                                                                                                                                         
  [RuntimeException]                                                                                                                     
  Failed to clone https://github.com/auraphp/installer-default.git, git was not found, check that it is installed and in your PATH env.  
                                                                                                                                         
  sh: 1: git: not found

エラー内容

下記 2 点

  1. Failed to clone https://github.com/xxxx.git, git was not found
  2. Failed to download xxxx from dist: The zip extension and unzip command are both missing

1. Failed to clone https://github.com/xxxx.git, git was not found

2. Failed to download xxxx from dist: The zip extension and unzip command are both missing

  • 原因
    1. PHP の zipエクステンション がインストールされてない
    2. OS の unzip コマンドがインストールされてない
  • 解消方法
    1. zipエクステンション をインストール (※ハマった事 を参照)
    2. unzip コマンド` をインストール
  • 反省点
    • エラーメッセージの英文をよく読んでおらず、エラー内容を勘違いしていた
      • unzip command が missing と書かれてにも関わらず、PHPの unzip エクステンション が足りないのだと勘違い
  • ハマった事
    • zip エクステンションをインストールするタイミング
      • Dockerfile に PHPエクステンションのビルドに必要な依存モジュールを、ビルドが終わって不要になったら削除する処理がある
      • 上記を把握せずに、依存モジュール削除後に、zip エクステンションをインストールしようとした為、ビルドが失敗

困っている事

  • エラー内容を正しく理解する前に、検討違いのキーワードでググったりと、遠回り(というか無駄な作業)をしまう。効率が悪い。無駄をなくしたい。