I'd like to have vendor/ moved out of the Drupal 8 root and symlink it. Composer doesn't have any problem with that (all commands work) but when I issue any drush command, even drush --version, it breaks.

Steps to reproduce:

$ composer create-project drupal-composer/drupal-project:8.x-dev website --stability dev --no-interaction --prefer-dist
$ cd website
$ mv vendor ..
$ ln -s ../vendor vendor
$ drush --version

PHP Warning:  require(/tmp/test1/vendor/composer/../../load.environment.php): failed to open stream: No such file or directory in /tmp/test1/vendor/composer/autoload_real.php on line 70
PHP Fatal error:  require(): Failed opening required '/tmp/test1/vendor/composer/../../load.environment.php' (include_path='/tmp/test1/vendor/pear/archive_tar:/tmp/test1/vendor/pear/console_getopt:/tmp/test1/vendor/pear/pear-core-minimal/src:/tmp/test1/vendor/pear/pear_exception:.:/usr/share/php') in /tmp/test1/vendor/composer/autoload_real.php on line 70

Full log: https://pastebin.com/raw/eMDgkdHV

Can I achieve this somehow? Even if I need to temporarily edit some path in an autoloader php script.

I need to do this on the vagrant based dev environment where I'd like to pull vendor/ out of the synced folder which is very very slow.

  • 1
    Drupal root normally lives inside /web, so /vendor already is outside the Drupal root. When moving vendor you also need to fix the autoloader. Moving vendor outside the project root probably is no good idea. – leymannx Oct 8 '19 at 5:43

I managed to solve it via specifying an absolute path in the vendor-dir configuration of composer.json: https://getcomposer.org/doc/06-config.md#vendor-dir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.