Description
I have no explanation for the following behavior. When running the same command under Docker, the generated classmap misses a few hundred mappings:
marvin /c/foo/bar> composer dump-autoload --no-scripts -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/c/foo/bar): git branch --no-color --no-abbrev -v
Failed to initialize global composer: Composer could not find the config file: /home/marvin/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading /c/foo/bar/vendor/composer/installed.json
Running 1.10.5 (2020-04-10 11:44:22) with PHP 7.3.14-1~deb10u1 on Linux / 4.19.84-microsoft-standard
Generating optimized autoload files
Generated optimized autoload files containing 6709 classes
marvin /c/foo/bar> docker run --rm -v /c/foo/bar:/app -w /app composer dump-autoload --no-scripts -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/app): git branch --no-color --no-abbrev -v
Failed to initialize global composer: Composer could not find the config file: /tmp/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading /app/vendor/composer/installed.json
Running 1.10.5 (2020-04-10 11:44:22) with PHP 7.4.5 on Linux / 4.19.84-microsoft-standard
Generating optimized autoload files
Generated optimized autoload files containing 6283 classes
Both commands are run under WSL 2. Running the Docker command from a Windows PowerShell doesn't change the output. (Installing PHP and composer under Windows I have not tried - it normally is a mess.)
I specifically miss class mappings of files defined in autoload.classmap
(Laravel project):
{
"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"database/migrations"
]
}
}
In total there are 310 (+2 .gitignore) files in this three directories, which is less than the difference mentioned. The vendor/composer/autoload_classmap.php
contains some of the classes in those directories though, just not all of them as I'd expect.
The only difference composer diagnose
gives, besides the fact that everything seems ok, is the PHP version: 7.3.14 under WSL2 vs. 7.4.5 under Docker.
Has anyone ever noticed something similar? I appreciate any valuable hint.
Update: 2020-04-22 14:26
After some diggin', tryin' and swearin' I'm now at the point where I know it must be related to WSL 2. If I use the old Docker for Windows backend (Hyper-V VM), it works fine. Also within the WSL 2, if I copy my project from the /c/foo/bar
path to an internal path like /home/marvin/foo/bar
and run the Docker container to dump-autoload
, the results are fine as well. So it must be an issue with the combination of WSL 2 as Docker backend and the mounted Windows drive.
Interestingly enough, when running docker run --rm -v /c/foo/bar:/app -w /app --entrypoint /bin/bash composer
using the WSL 2 Docker backend, the scandir()
PHP function for example returns all the files for which I'm missing the mapping within the classmap. So the files are there and permissions are fine, they just don't seem to be handled correctly.