Laravel Forge Deploy error: "http urls require a HttpDownloader instance to be passed"

78 Views Asked by At

I'm trying to deploy a laravel application using Laravel Forge and am getting this in my logs when I try to deploy.

Thu Jul 20 22:14:23 UTC 2023
From github.com:jas0123uah/noted_laravel
 * branch            main       -> FETCH_HEAD
Already up to date.
Running 2.5.8 (2023-06-09 17:13:21) with PHP 8.2.8 on Linux / 5.15.0-76-generic
Reading ./composer.json (/home/forge/default/composer.json)
Reading ./composer.json (/home/forge/default/composer.json)

In JsonFile.php line 65:
                                                            
  [InvalidArgumentException]                                
  http urls require a HttpDownloader instance to be passed  
                                                            

Exception trace:
  at phar:///usr/local/bin/composer/src/Composer/Json/JsonFile.php:65
 Composer\Json\JsonFile->__construct() at phar:///usr/local/bin/composer/src/Composer/Factory.php:181
 Composer\Factory::createConfig() at phar:///usr/local/bin/composer/src/Composer/Factory.php:460
 Composer\Factory::createGlobal() at phar:///usr/local/bin/composer/src/Composer/Command/BaseCommand.php:235
 Composer\Command\BaseCommand->initialize() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:264
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:378
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:141
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:88
 require() at /usr/local/bin/composer:29

I tried Googling, but I couldn't find anything about passing an HttpDownloader instance to composer. I'm not sure what is wrong. I was previously deploying just fine. If it's possibly related, I renamed the default branch from 'master' to 'main' before this happened

This is my deploy script:

cd /home/forge/default
git pull origin $FORGE_SITE_BRANCH

$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader

( flock -w 10 9 || exit 1
    echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock

if [ -f artisan ]; then
    $FORGE_PHP artisan migrate --force
fi
npm i 
npm run build
rm -rf node_modules

Message after updating composer

Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  laravel/sail ........................................................................ DONE  
  laravel/sanctum ..................................................................... DONE
  laravel/tinker ...................................................................... DONE  
  laravel/ui .......................................................................... DONE  
  nesbot/carbon ....................................................................... DONE  
  nunomaduro/collision ................................................................ DONE  
  nunomaduro/termwind ................................................................. DONE  
  spatie/laravel-ignition ............................................................. DONE  

81 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].

No security vulnerability advisories found
1

There are 1 best solutions below

0
amac On

Here try this and see if it helps. I think php-fpm is not correctly restarting and perhaps causing issues. Please try this. Ya even more so I think you are pointing at your default forge config instead of the version or branch or project you are actually want to do. Therefore you are most likely assuming that things are updating but aren't because they are set differently from the version you intend to run your application from. CLI vs php-fpm.

Be sure to update places accordingly. Also in your post it would be nice if you could share some of the variables passed into your file like $PHP_FPM, etc...

Actually I am almost regretting on attempting to answer because there are plenty of questions that are probably best sharing within your team as they are sensitive to the security of your project. However, if not, you are sharing your github, You are moving into the default directory (not typical in forge) that may already have a running php version that differs from the version you are expecting your application to run on. You need to ensure you are correctly restarting php-fpm sock linked to that directory. You want to also be sure you are commiting the correct version of your composer.lock and composer.json considering you said you made some changes that may have shifted your dependencies incorrectly. you will also want to make sure that the composer version matches yours on either dev, test, staging, local, prod. Do not commit your node_modules or vendor folders as well. Answering those questions is a start. After that you may need to share more detailed information.

Also Delete vendor and composer.lock ensure your composer.json is correct with other developers then composer install. This may have an effect depending on the correctness of the lock file and perhaps differences in the vendor folder or composer version.

Ya taking another look. You are discovering packages in your autoload that are different than what your composer.lock is insisting that you have. You definitely have inconsistencies there.

cd /home/forge/<PROJECT_DOMAIN_HERE... should not be default>

git pull origin $FORGE_SITE_BRANCH

ProjectDirectory=/usr/local/bin/wp

$ProjectDirectory rm -rf vendor composer.lock

echo $FORGE_COMPOSER 

echo $FORGE_PHP

composer update --no-dev --no-interaction --prefer-dist --optimize-autoloader --vvv --force

( flock -w 10 9 || exit 1

    echo 'Restarting FPM...'; sudo -S service php8.2-fpm reload ) 9>/tmp/fpmlock

Just print of lot of these variables and see what makes sense

here