Well, I worked around this issue by using the laravel installer instead. Now composer works fine. I can add packages to composer.json and do a composer update and everything works. So weird. I've never used the laravel installer before and composer create-project as always worked in the past. I guess I'll be switching now. :D
Composer install failing, vendor folder missing
This is an odd one for me. Been using Homestead since it came out, composer longer than that, countless Laravel projects. Never once have I had this issue before and it's baffling me. Thought I would throw it out here in case I am missing something obvious.
I have a new install of Homestead and a new Laravel project. Like I always do, I run composer create-project inside the Homestead VM to get started. Not once has this failed me before, until today. The result is that laravel/laravel gets downloaded, but no dependencies are installed. The vendor folder is missing. Composer tries to run the post install commands, but they fail obviously since vendor is missing. I'm ssh'd in as the vagrant user and permissions are correct. I even tried sudo and I get nothing. Composer.json is in the root of the project and looks good. Not sure what's going on, but here's the output:
vagrant@homestead:/var/www$ sudo composer create-project --prefer-dist laravel/laravel myproject.app
Installing laravel/laravel (v5.2.15)
- Installing laravel/laravel (v5.2.15)
Downloading: 100%
Created project in myproject.app
> php -r "copy('.env.example', '.env');"
> php artisan clear-compiled
PHP Warning: require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstrap/autoload.php on line 17
Warning: require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstrap/autoload.php on line 17
PHP Fatal error: require(): Failed opening required '/var/www/myproject.app/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:') in /var/www/myproject.app/bootstrap/autoload.php on line 17
Fatal error: require(): Failed opening required '/var/www/myproject.app/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:') in /var/www/myproject.app/bootstrap/autoload.php on line 17
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
[RuntimeException]
Error Output: PHP Warning: require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstra
p/autoload.php on line 17
PHP Fatal error: require(): Failed opening required '/var/www/myproject.app/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:') in /var/www/myproject.app/boots
trap/autoload.php on line 17
Running composer install or composer update results in the same.
With more verbose, I get this:
vagrant@homestead:/var/www/myproject.app$ composer -vvv install
Reading ./composer.json
Loading config file ./composer.json
Checking CA file /etc/ssl/certs/ca-certificates.crt
Executing command (/var/www/myproject.app): git branch --no-color --no-abbrev -v
Executing command (/var/www/myproject.app): git describe --exact-match --tags
Failed to initialize global composer: Composer could not find the config file: /home/vagrant/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
> pre-update-cmd: php artisan clear-compiled
Executing command (CWD): php artisan clear-compiled
PHP Warning: require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstrap/autoload.php on line 17
Not sure why I'm getting the whole "Failed to initialize global composer" thing. I googled it and came up with nothing relevant. Any ideas?
Looks like I'm not the only one. There was an update to composer that broke things. The fix is to update your composer.json file.
Please or to participate in this conversation.