-
Notifications
You must be signed in to change notification settings - Fork 185
Description
Describe the bug
Composer Autoloader files are not re-created on a cached build.
On the initial build the following command is ran composer install --no-dev --no-progress --no-interaction --optimize-autoloader. This triggers a Generating optimized autoload files which includes all classes which exist in the workspace including any composer dependencies.
On the next build using a cache, this existing composer autoloader files are used which may not contain updates to the local workspace i.e. removed or added classes. Added classes are not an issue since the autoloader falls back to searching the file system but removed classes are attempted to be loaded on system startup which causes the warning shown at the bottom.
I've added a PR which runs composer dump-autoload --optimize to resolve this (untested, see comment).
Additional context
How are you using GCP buildpacks?
-
packand thegcr.io/buildpacks/builder - Cloud Functions
- Cloud Run
- Cloud Build
- App Engine Standard
- App Engine Flex
- Firebase App Hosting
Did this used to work?
No
What language is your project primarily written in?
PHP
Steps To Reproduce
Steps to reproduce the behavior:
- Run an appengine PHP build (try using a example repo such laravel)
- Delete a PHP class
- Rerun an appengine PHP build (which should use the composer cache)
- A - Explore the container image and view the
vendor/composer/autoload_classmap.phpfile which contains the missing file - B - Whilst hitting with requests you should notice the below warning
Expected behavior
No warning thrown / existing autoloader does not contain files which no longer exist.
Actual behavior
The below error is triggered due to the composer autoloader listing files which no longer exist.
E_WARNING: include(/workspace/vendor/composer/../../www/Internal files/Purchase.php): Failed to open stream: No such file or directory