LoginSignup
okuurt
@okuurt (徹 小山)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

shoPHP/Laravel デプロイがエラーになり失敗する。Dependency installation failed!

解決したいこと

ここに解決したい内容を記載してください。

Herokuにデプロイをしたい。
docker環境でアプリを作りながら学んでいます。
localhost上では、問題なく動かすことができます。

発生している問題・エラー

スクリーンショット 2021-03-01 17.43.27.png

省略〜

remote:        Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
remote:        Generating optimized autoload files
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        > @php artisan package:discover --ansi
remote:        
remote:        In AppServiceProvider.php line 26:
remote:                                                  
remote:          Class "App\Providers\Schema" not found  
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: b38902e5fb735380a245d461249103b3034a9fcf
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version b38902e5fb735380a245d461249103b3034a9fcf
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 my-laravel-app-super.
remote: 
To https://git.heroku.com/my-laravel-app-super.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-laravel-app-super.git'

heroku log

または、問題・エラーが起きている画像をここにドラッグアンドドロップ

該当するソースコード

my-laravel-app/app/Providers/AppServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;  追加しても解決できない

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
        if (\App::environment('production')) {
            \URL::forceScheme('https');
        }
    }
}

docker-compose.yml
version: '3'
services:
  web:
    image: nginx:1.15.6
    ports:
      - '8000:80'
    depends_on:
      - app
    volumes:
      - ./docker/web/default.conf:/etc/nginx/conf.d/default.conf
      - .:/var/www/html
  app:
    build: ./docker/php
    volumes:
      - .:/var/www/html
    depends_on:
      - mysql
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: sample
      MYSQL_USER: user
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql
volumes:
  mysql-data:
my-laravel-app/.env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:mNbZD8K3m26KOsDrBDFvLZ0Wg2UkCCfJMcTlX8lXqK8=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=sample
DB_USERNAME=user
DB_PASSWORD=password

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"


自分で試したこと

Aの参考記事をみながらherokuへデプロイをしていました。

Heroku Procfileを作成する
記述)web: vendor/bin/heroku-php-apache2 public/

varchar型の文字数を191に制限
記述)
use Illuminate\Support\Facades\Schema;

↑これを初め書き忘れていたので、追加しました。追記してコミットをしてもう一度やり直しても、エラー解消されません。

public function boot()
{
Schema::defaultStringLength(191);
}

herokuに変更をプッシュする
$ git add -A .
$ git commit -m ""
(すべてコミット済み)

$ git push heroku master
エラーになってしまう箇所

参考記事
A) https://qiita.com/tamappe/items/a175596e9aec725e1d2d
https://qiita.com/rope19181/items/07d556715a3a4f6191bd

B) https://teratail.com/questions/96802

補足情報(FW/ツールのバージョンなど)

heroku 7.49.1
docker環境
Laravel Framework 7.30.4

0

No Answers yet.

Your answer might help someone💌