12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【PHP】Composer installしようとしたら、warning: The lock file is not up to date with the latest changes in composer.json.となった時の対処

Posted at

デプロイを行う際に毎度composer installを行っていたんですが、

warning: The lock file is not up to date with the latest changes in composer.json.You may be getting outdated dependencies. Run update to update them.

このエラーがでていました。それも長いことでていました。今回はこのエラーの対処方法を書いておきます

composer.jsonとcomposer.lockに違いがある

composer install と composer updateの違い - Qiita

そもそもcomposer.jsonとcomposer.lockの違いについて知らなかったのでそこから

composer.lock:現在使用しているバンドルのバージョン等が管理されます。
composer.json:必要となるバンドルを記述します。

composer install:composer.lockに書かれている各ライブラリをインストールする。
composer update:composer.jsonをもとに各ファイルを最新版にアップデートする。composer.lockのアップデートも

はい。またこの記事によると

composer の「Warning: The lock file is not up to date ~」 - Qiita

composer install で次の警告が表示されたのでなんなのか調べました。

Warning: The lock file is not up to date with the latest changes in ...

composer.lockにはcomposer.jsonのハッシュ値が記録されておりこれが少しでもずれているとこのエラーがでてくるようです。

解決

composer update --lock

このコマンドでcomposer.lockに記録されたハッシュ値のみを更新できるようなので
これを実行するとハッシュ値が合い、エラーが解消されました。

12
4
0

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
12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?