错误:无法解析'composer.lock';它必须是Composer生成的有效锁文件

时间:2016-10-07 09:16:50

标签: php git heroku composer-php

我正在尝试将一个简单的应用程序部署到Heroku,但不断收到此错误消息:

Alastairs-MacBook-Air:php-getting-started alastair$ git push heroku master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.23 KiB | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote: 
remote:  !     ERROR: Couldn't parse 'composer.lock'; it must be a valid lock
remote:        file generated by Composer. Run 'composer update', add/commit
remote:        the change, then push again.
remote: 
remote:  !     Push rejected, failed to compile PHP app
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to arcane-peak-94383.
remote: 
To https://git.heroku.com/arcane-peak-94383.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/arcane-peak-94383.git'

就是这个tutorial

我多次运行composer update,添加/提交更改,并重新安装composer。一切都没有运气。 composer.lock文件由Composer生成,因为我通过运行composer update重新生成它。

这是我的composer.json文件:

{
 "require" : {
"silex/silex": "^1.3",
"monolog/monolog": "^1.4",
"twig/twig": "^1.8",
"symfony/twig-bridge": "^2",
"alrik11es/cowsayphp": "^1.0"
  },
  "require-dev": {
"heroku/heroku-buildpack-php": "*"
 }
}

我知道这是一个简单的解决方案,但我现在已经尝试解决了几个小时。提前谢谢。

1 个答案:

答案 0 :(得分:1)

应该这样做的answer from SO

似乎Heroku仅支持最新版本的Composer。

composer self-update以及composer update(+ git add,+ git commit)应解决此问题。