bergben
bergben

Reputation: 1415

Push Respond CMS to Heroku: no 'composer.lock' was found

I want to host Respond CMS on Heroku, so I did:

  1. git clone of the respondcms repository
  2. heroku create in that folder
  3. git push heroku master

I always get the following error in the terminal:

remote: ----->PHP app detected
remote:
remote:  !     ERROR: Your 'composer.json' lists dependencies inside 'require',
remote:        but no 'composer.lock' was found. Please run 'composer update' to
remote:        re-generate 'composer.lock' if necessary, and commit it into your
remote:        repository. For more information, please refer to the docs at
remote:        https://devcenter.heroku.com/articles/php-support#activation
remote:
remote:
remote:  !     Push rejected, failed to compile PHP app
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to app-name

I ran composer update and that works fine, also there is a composer.lock file in the folder.

Why isn't this working?

Upvotes: 0

Views: 7403

Answers (1)

Chris
Chris

Reputation: 137075

The composer.lock file doesn't just have to exist locally, it has to be committed. That way it will be included when you push to Heroku.

Try something like this:

  • git add composer.lock
  • git commit using a message like Add Composer lock file
  • git push heroku (or whatever your remote is called)

The reason for this is that composer.json generally specifies dependencies in a somewhat vague way, e.g. "whatever the latest 1.2.x release is" or "the latest commits on the master branch". You can probably imagine that you and I might get different results depending on when we install our dependencies.

The composer.lock file's job is to lock these dependencies down in a more rigorous way. If you install the latest 1.2.x release of a library, its precise version is recorded in composer.lock, e.g. "version 1.2.2 at Git hash 1234abc".

In general, unless you are deliberately updating libraries it is better to use composerinstall, not composer update. The former uses the exact versions from the lock file and doesn't update anything. That way we can have more confidence that we are using identical libraries. The latter updates new versions and changes the lock file.

I've never used Heroku with PHP, but it makes sense that it wants to install the exact versions listed in the lock file.

Upvotes: 8

Related Questions