独学で作ったWEBサービス(phpで作成)をherokuにデプロイしようと思っているのですが、エラーが出て先に進めないのでお力添えをお願いしたいです。
herokuのドキュメントを読み、composerをインストールしました。
herokuのアプリ作成(git create)までは問題なくできています。
公式の案内を見ると次はgit push heroku mainコマンドを打つのですが、これがどうにもうまくいきません。
以下、少し長いのですがエラー文を記載します。
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> PHP app detected
remote:
remote: NOTICE: Your 'composer.json' is completely empty!
remote:
remote: A completely empty file is not a valid JSON document.
remote:
remote: Heroku automatically corrected this problem, but it is strongly
remote: recommended you change the contents to at least '{}'.
remote:
remote: For documentation on Composer and dependency management, check
remote: out the introduction at https://getcomposer.org/doc/00-intro.md
remote:
remote: -----> Bootstrapping...
remote:
remote: ! WARNING: Your 'composer.lock' is out of date!
remote: !
remote: ! The 'composer.lock' file in your project is not up to date with
remote: ! the main 'composer.json' file. This may result in installation
remote: ! of incorrect packages or package versions.
remote: !
remote: ! The lock file is required in order to guarantee reliable and
remote: ! reproducible installation of dependencies across systems and
remote: ! deploys. It must always be kept in sync with 'composer.json'.
remote: !
remote: ! Whenever you change 'composer.json', ensure that you perform
remote: ! the following steps locally on your computer:
remote: ! 1) run 'composer update'
remote: ! 2) add all changes using 'git add composer.json composer.lock'
remote: ! 3) commit using 'git commit'
remote: !
remote: ! Ensure that you updated the lock file correctly, and that you
remote: ! ran 'git add' on both files, before deploying again.
remote: !
remote: ! Please remember to always keep your 'composer.lock' updated in
remote: ! lockstep with 'composer.json' to avoid common problems related
remote: ! to dependencies during collaboration and deployment.
remote: !
remote: ! Please refer to the Composer documentation for further details:
remote: ! https://getcomposer.org/doc/
remote: ! https://getcomposer.org/doc/01-basic-usage.md
remote:
remote:
remote: ! WARNING: Non-stable 'minimum-stability'!
remote: !
remote: ! Your 'composer.json' contains a 'minimum-stability' setting of
remote: ! '', and the 'prefer-stable' setting is not enabled.
remote: !
remote: ! This combination of options may negatively impact the stability
remote: ! of your app and result in crashes as it permits installation of
remote: ! dev, alpha, beta, or RC versions of PHP runtimes and extensions.
remote: !
remote: ! If possible, you should always use explicit stability flags on
remote: ! only those dependencies that you want unstable versions of, and
remote: ! leave 'minimum-stability' at its default 'stable' setting.
remote: !
remote: ! If you really need a global 'minimum-stability' setting lower
remote: ! than 'stable', it is strongly recommended that you enable the
remote: ! 'prefer-stable' setting in 'composer.json'.
remote: !
remote: ! For more information, refer to the following documentation:
remote: ! https://getcomposer.org/doc/articles/versions.md
remote: ! https://getcomposer.org/doc/04-schema.md#package-links
remote: ! https://getcomposer.org/doc/04-schema.md#minimum-stability
remote: ! https://getcomposer.org/doc/04-schema.md#prefer-stable
remote:
remote: -----> Installing platform packages...
remote:
remote: ! ERROR: Failed to parse 'composer.lock'!
remote: !
remote: ! There was an error parsing 'composer.lock'; it must be a valid
remote: ! file generated by Composer and be in an up-to-date state.
remote: !
remote: ! Look above for any parse errors and address them if necessary.
remote: !
remote: ! You most likely created or edited the file by hand, or a merge
remote: ! conflict was not resolved properly, resulting in a syntax error
remote: ! in the file. Refer to the docs for information on re-generating
remote: ! the lock file: https://getcomposer.org/doc/01-basic-usage.md
remote: !
remote: ! Please perform the following steps locally on your computer to
remote: ! resolve this issue before attempting another deploy:
remote: ! 1) Run 'composer update' to re-generate the lock file
remote: ! 2) stage the lock file changes using 'git add composer.lock'
remote: ! 3) commit the change using 'git commit'
remote: !
remote: ! You can run 'composer validate' locally on your computer for
remote: ! further diagnosis. Remember to also always keep your lock file
remote: ! up to date with any changes according to the instructions at
remote: ! https://getcomposer.org/doc/01-basic-usage.md
remote: !
remote: ! Please remember to always keep your 'composer.lock' updated in
remote: ! lockstep with 'composer.json' to avoid common problems related
remote: ! to dependencies during collaboration and deployment.
remote: !
remote: ! REMINDER: the following warnings were emitted during the build;
remote: ! check the details above, as they may be related to this error:
remote: ! - Your 'composer.lock' is out of date!
remote: ! - Non-stable 'minimum-stability'!
remote:
remote: ! Push rejected, failed to compile PHP app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: e16861394a1f887ef98bc0bf00d8faf14bb6d1fe
remote: !
remote: ! We have detected that you have triggered a build from source code with version e16861394a1f887ef98bc0bf00d8faf14bb6d1fe
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to safe-meadow-50745.
remote:
To https://git.heroku.com/safe-meadow-50745.git
! [remote rejected] heroku-test -> heroku-test (pre-receive hook declined)
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/safe-meadow-50745.git'
英語があまり得意ではないのですが、何となく読んでみると、原因は以下の3つでしょうか?
①__NOTICE: Your 'composer.json' is completely empty!__
→brew install composer と composer init のコマンドを叩いた時に自動で’composer.json’が作成され、中身も一応書いてあるので、「empty」なはずはないと思っているのですが、、、
②__WARNING: Your 'composer.lock' is out of date!__
ERROR: Failed to parse 'composer.lock'!
→これが一番の原因な気がしています。”時代遅れ”だの”解析できない”だのと言われるということは、現在のバージョンにあった書き方になっていない、という解釈でいいのでしょうか?違うのでしょうか。。
③WARNING: Non-stable 'minimum-stability'!
→これはjsonの方の書き方が良くない?ということなのでしょうか。
大変長くなってしまったのですが、自分の解釈としては「頑張ってバージョンに合った書き方を調べて直せばherokuへデプロイできるはず」と考えているのですが、この解釈で間違い無いのでしょうか?それとも他の何かが原因なのでしょうか。
拙い質問で申し訳ありません。よろしくお願い致します。
【追記】
composer.jsonとcomposer.lockの内容を記載します。内容は自分ではいじっていません。
●composer.json
json
1{ 2 "name": "masataka.f/heroku-test", 3 "autoload": { 4 "psr-4": { 5 "MasatakaF\HerokuTest\": "src/" 6 } 7 }, 8 "authors": [ 9 { 10 "name": "MASATAKA", 11 "email": "mstk_bz.tak.koshi@icloud.com" 12 } 13 ], 14 "require": {} 15} 16
●composer.lock
json
1コード 2 3{ 4 "_readme": [ 5 "This file locks the dependencies of your project to a known state", 6 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 7 "This file is @generated automatically" 8 ], 9 "content-hash": "e48ea706644c9096610ec479504299a8", 10 "packages": [], 11 "packages-dev": [], 12 "aliases": [], 13 "minimum-stability": "stable", 14 "stability-flags": [], 15 "prefer-stable": false, 16 "prefer-lowest": false, 17 "platform": [], 18 "platform-dev": [], 19 "plugin-api-version": "2.2.0" 20} 21
以上、よろしくお願い致します。
あなたの回答
tips
プレビュー