7

I am trying to run a PHP file in a Vagrant VM which also uses composer for the build.

I am getting the following errors:

PHP Warning:  require(/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php): failed to open stream: No such file or directory in /var/www/ispe/vendor/composer/autoload_real.php on line 66

Warning: require(/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php): failed to open stream: No such file or directory in /var/www/CLIENT/vendor/composer/autoload_real.php on line 66
PHP Fatal error:  require(): Failed opening required '/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/CLIENT/vendor/composer/autoload_real.php on line 66

Fatal error: require(): Failed opening required '/var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/CLIENT/vendor/composer/autoload_real.php on line 66

Now as far as I can tell, phpseclib shouldn't be required for this particular functionality, or anything else (though I haven't 100% confirmed the anything else bit yet).

Even so, I decided to add it to my composer.json ("phpseclib/phpseclib": "2.0.4") to get rid of the errors, with no luck.

I'm fairly new to Composer, so I am wondering precisely what I might be doing wrong here or what needs to be setup.

I can confirm that the directory /var/www/CLIENT/vendor/composer/../phpseclib/phpseclib/phpseclib/ exists, however there is no file bootstrap.php inside the directory.

Instead I see the following:

Crypt  File  Math  Net  System

EDIT: I also want to clarify that the file autoload.php is inside the vendor directory and that the PHP version of the VM is 7.0.

Steven Matthews
  • 9,705
  • 45
  • 126
  • 232
  • Composer does not only download your dependencies, it also recursively downloads dependencies of dependencies. If you are not using this library directly, it is likely a dependency of one that you are using, or one that one of those is using. You can try grepping for phpseclib in */composer.json within your vendor directory to get a better idea what is including it. – mopsyd Dec 21 '16 at 18:41

2 Answers2

24

I strongly believe that the cache is the problem, It cannot be 100% sure but try destroying your Vagrant instance, or

You could follow the following steps:

  1. Delete the vendor folder
  2. Delete composer.lock
  3. Run the command composer clearcache (or clear-cache)
  4. Run composer install
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Saumya Rastogi
  • 13,159
  • 5
  • 42
  • 45
2

Oneliner for easy copy/pasting:

rm -rf vendor composer.lock && composer clearcache && composer install
Flyke
  • 347
  • 3
  • 5
  • Please add some explanation to your answer such that others can learn from it. Especially as removing the lock file can have severe consequences – Nico Haase Aug 19 '21 at 13:25
  • This should probably be a comment under the accepted answer as it does what the answer suggests in a single line – Kerwin Sneijders Oct 13 '21 at 14:16
  • I'm getting the same error but I don't have any composer.lock or composer.json files so I can't do the reinstall. I have no idea how this is even working without those files. – Andrew Christensen Jan 13 '22 at 01:47