Closed
Description
When using the COMPOSER_VENDOR_DIR
setting to specify a vendor path outside of the Magento installation root, Magento's autoloader registration fails to generate the correct path.
Preconditions
- Any host with access to two separate parent directories.
- Any recent version of composer installed
Steps to reproduce
- Create a temporary directory for vendor data:
mkdir /tmp/composer-vendor-dir
- Create a project directory:
mkdir ~/magento-project
- Set the Composer vendor directory:
export COMPOSER_VENDOR_DIR="/tmp/composer-vendor-dir"
- Create a Magento project:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition ~/magento-project
- Observe successful Composer installation
- Attempt to access Magento CLI:
php bin/magento
Expected result
- Using
php bin/magento
should produce a command list
Actual result
- Error message given:
Autoload error: Vendor autoload is not found. Please run 'composer install' under application root directory.
Additional Information
File app/autoload.php
incorrectly assumes a vendor path relative to the project:
define('BP', dirname(__DIR__));
...
$vendorAutoload = BP . "/{$vendorDir}/autoload.php";
Which in the example scenario given produces a path like:
/home/user/magento-project//tmp/composer-vendor-dir/autoload.php
The validation of $vendorAutoload
should be modified to resolve variations of the assembled path, in a way that it can accept an absolute path returned by app/etc/vendor_path.php
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release