composer: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in ../vendor/composer/autoload_namespaces.php on line 14
Composer gets broken at a composer install
after switching branches in my project. It is giving a Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in /projects/dashboard/vendor/composer/autoload_namespaces.php on line 14
at the Generating autoload files step of the install.
Since it is indicated at the autoload file I tried to composer dump-autoload
resulting in the exact same error.
I can only fix this by removing the entire /vendor/composer folder and composer install
after.
The resulting autoload_namespaces.php file is however exactly the same after this.
Output of composer diagnose
:
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.9.3
PHP version: 7.3 - Package overridden via config.platform (actual: 7.3.14)
PHP binary path: /usr/bin/php7.3
When I run this command:
composer install
composer dump-autoload
I get the following output:
...
Generating autoload files
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in /projects/dashboard/vendor/composer/autoload_namespaces.php on line 14
Contents of autoload_namespaces.php
:
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Rize\\UriTemplate' => array($vendorDir . '/rize/uri-template/src'),
'Pimple' => array($vendorDir . '/pimple/pimple/src'),
'Google_Service_' => array($vendorDir . '/google/apiclient-services/src'),
'Google_' => array($vendorDir . '/google/apiclient/src'),
);
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (7 by maintainers)
Hi,
I managed to reproduce and fix this.
Config : Vagrant 2.2.5 , VBox 6.0.20, PHP 7.3.17-1+0~20200419.57+debian9~1.gbp0fda17 (cli), sur Mac OS Catalina.
my original
composer/autoload_namespaces.php
file was :And throws the same error :
I fixed this by removing the last coma at the end of the last value of array :
No other explanation…
Thank you @Black0wI This fixed the problem for me, too!