错误:无法解析“composer.lock”;它必须是 Composer 生成的有效锁文件
Posted
技术标签:
【中文标题】错误:无法解析“composer.lock”;它必须是 Composer 生成的有效锁文件【英文标题】:ERROR: Couldn't parse 'composer.lock'; it must be a valid lock file generated by Composer 【发布时间】:2017-02-16 05:51:03 【问题描述】:我正在尝试将一个简单的应用程序部署到 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": "*"
我知道这是一个简单的解决方案,但我已经尝试解决几个小时了。提前致谢。
【问题讨论】:
你能出示你的composer.json
吗?
当然 - 将添加到我的原始帖子中。谢谢。
看起来不错.. 你是否在提交中包含了composer.lock
文件?
很确定我有。我还没有.gitignore
'd 它。似乎表明这是正确的做法here
得到这个:git status On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits) nothing to commit, working directory clean
【参考方案1】:
应该这样做的answer from SO:
似乎 Heroku 只支持最新版本的 Composer。
composer self-update
和 composer update
(+ git add
, + git commit
) 应该可以解决此问题。
【讨论】:
以上是关于错误:无法解析“composer.lock”;它必须是 Composer 生成的有效锁文件的主要内容,如果未能解决你的问题,请参考以下文章
composer update的错误使用以及如何更新composer.lock文件
从composer.lock(不是composer.json)重新安装供应商