Composer "Generating optimized autoload files" very slow
Hey,
Asking on here as a fresh because I have seen a number of historic posts about a similar issue however the solutions haven't helped me or my colleague.
Its a large repo but other colleagues using Mac and Linux OS's have no problem. Just myself and another colleague both running on Mac OS Sonoma. The "Generating optimized autoload files" consistently takes between 300 and 400 seconds to run. On the same project on other machines its about 20s.
See below trace (I've omitted non relevant updates)
[19.7MiB/8.30s] Installing dependencies from lock file (including require-dev)
[20.8MiB/8.30s] Verifying lock file contents can be installed on current platform.
[21.1MiB/8.31s] Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run composer update or composer update <package name>.
[26.3MiB/60.37s] Generating optimized autoload files
[51.2MiB/455.23s] Warning: Ambiguous class resolution, "FPDF" was found in both "/home/tmstores/www/app/functions/Services/External/FPDF.php" and "/home/tmstores/www/vendor/iio/libmergepdf/tcpdi/tcpdi.php", the first will be used.
[72.0MiB/479.08s] > Illuminate\Foundation\ComposerScripts::postAutoloadDump
[91.3MiB/485.32s] > @php artisan package:discover --ansi
The previous solution was to register packagist in the repos with https
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.org"
}
}
Although the above solution helped originally, the issue some came back.
I found that my anti-virus was causing the some delay for each file that was being checked as part of the auto loader. Adding the project directory and the process of the IDE to the exclusion list of the AV resolved the issue fully :)
Thanks! @smily! Never knew windows defender was slowing it down. I excluded the whole project folder of mine as you suggested and the time drastically reduced from minutes to seconds!
In my case, trying to disable Windows Defender processes is much faster, taking less than 2 minutes. If Windows Defender is on, it takes more than 10 minutes.