jaydeluca
2 years ago
454
25
Forge

"It is unsafe to run Dusk in production." error when trying to deploy

Posted 2 years ago by jaydeluca

For some reason when running the following deploy script, my app all of sudden is trying to run dusk on production deployment, and throwing an error. I do have dusk installed and have written some tests, but that was over a month ago, and i've made 100+ commits and many deployments without issue.

Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize

                                           
  [Exception]                              
  It is unsafe to run Dusk in production.  
                                           

Script php artisan optimize handling the post-install-cmd event returned with error code 1

Here is my deploy Script:

# stop script on error signal
set -e

# remove old deployment folders
if [ -d "/home/forge/deploy" ]; then
  rm -R /home/forge/deploy
fi
if [ -d "/home/forge/backup" ]; then
  rm -R /home/forge/backup
fi

cp -R /home/forge/app-name.com /home/forge/deploy

# Update
cd /home/forge/deploy
git stash
git pull origin production

composer install --no-interaction --no-dev --prefer-dist

yarn
npm run production

# Reset opcache
echo "" | sudo -S service php7.0-fpm reload

# Switch (downtime for microseconds)
mv /home/forge/app-name.com /home/forge/backup
mv /home/forge/deploy /home/forge/app-name.com

# Cache All The Things for Performance
cd /home/forge/app-name.com
php artisan view:clear
php artisan route:cache
php artisan config:cache

In my app service provider:

    public function register()
    {
        // Dusk, if env is appropriate
        if ($this->app->environment('local', 'testing')) {
            $this->app->register(DuskServiceProvider::class);
        }
    }

So then I went through and removed every instance of Dusk in my app, and now the deploy is failing with the following error:

> php artisan optimize

                                                           
  [Symfony\Component\Debug\Exception\FatalThrowableError]  
  Class 'Laravel\Dusk\DuskServiceProvider' not found       
                                                           

Script php artisan optimize handling the post-install-cmd event returned with error code 1

We have tried clearing cache, opcache, all kinds of things to no avail. Any ideas?

Please sign in or create an account to participate in this conversation.