Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

niloy's avatar
Level 5

Dependency installation failed

I' getting this error while deploying API to heroku.

remote:        Generating optimized autoload files
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        > @php artisan package:discover --ansi
remote:        
remote:        In CryptKey.php line 52:
remote:                                                                                       
remote:          Key path "file:///tmp/build_a8bd6864/storage/oauth-private.key" does not ex  
remote:          ist or is not readable                                                       
remote:                                                                                       
remote:        
remote:        Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
remote:  !     WARNING: A post-autoload-dump script terminated with an error
remote: 
remote:  !     ERROR: Dependency installation failed!
remote:  !     
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !     
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !     
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !     
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
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:  !     - A post-autoload-dump script terminated with an error
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: 2084aa011f3c0e5b395af053a556d46d7d1e3a1f
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 2084aa011f3c0e5b395af053a556d46d7d1e3a1f
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 minute-man-api.
remote: 
To https://git.heroku.com/minute-man-api.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/minute-man-api.git'

Thanks for your time.

0 likes
1 reply
rodrigo.pedra's avatar

If you are using Laravel Passport you might be missing its key on the storage folder:

https://laravel.com/docs/8.x/passport#deploying-passport

You'll need to run this on your server:

php artisan passport:keys

The weird thing to me is that it was using a temp folder as the app's storage. Might be something from Heroku, or serverless I am not aware of.

One other detail: composer didn't fail on installing the dependencies, it failed on executing the post-autoload-dump script. So your dependencies might be installed correctly.

If you need to recreate passport keys on every deployment you can add the above command to your composer.json file post-autoload-dump script (look under the scripts key)

But I don't think that is a good idea as it would invalidate all previous tokens on each deploy.

As I am not familiar with Heroku, or Serverless, I don't know how to workaround having your app's storage as a temp folder on the server.

Please or to participate in this conversation.