framework: [5.5] Cannot clear package auto-discovery cache
- Laravel Version: 5.5.3
- PHP Version: 7.1
- Database Driver & Version: Not relevant
Description:
If package providers cache becomes invalid it is impossible to clear it with clear-compiled command. But clear-compiled command looks right tool to use.
By invalid cache I mean bootstrap/cache/packages.php contains non-existing package service providers.
We commit all code from vendor folder to git. There are reasons for this.
When we switch branches some dependencies can disappear but cache still contains them.
This was not an issue before package discovery.
Also I can clean cache only manually deleting bootstrap/cache/packages.php.
clear-compiled fails because it loads non-existing service providers for some reason.
Steps To Reproduce:
- install auto-discoverable package for example laravel/passport
- delete this package manually from vendor folder
- open home page, error happens: laravel loads non-existing PassportServiceProvider
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 10
- Comments: 20 (4 by maintainers)
@themsaid, composer dump-autoload do no solve this problem - after running you still have nonexistent provider classes inside
bootstrap/cache/config.phpand all artisan commands will fail. Moreover, seems this bug can be fixed only by hands withrm bootstrap/cache/config.php😦I think this should be reopened and fixed.
I agree with @LastDragon-ru, I went through same thing today, only
rm bootstrap/cache/config.phpsolved the issue and has restored all commands.Neither of these were working:
All of them were showing
Class 'XXX' not found.How did I get there? I’ve installed a package (
composer require package-name), didn’t like it, went back on the version control, runninggit checkout -- .+rmcreated files, then tried all said above.It’d be cool if
php artisan cache:clearcould solve that.I think the issue should be re-opened.
You can run
php artisan package:discover.Same issue here. We are using Laravel Forge with quick-deploy on our staging environments and the deployment scripts fail in the described cases. The only fix is to manually ssh into the server and
rm bootstrap/cache/config.php. Definitely needs a fix!It’s not a bug in the framework, you can use the forum for discussions or if you have a suggestion please use the https://github.com/laravel/internals repo.
A composer dump-autoload after each deploy would solve your issue but it seems like you have a special installation method out of the norm, so I suggest you seek help on the forums.
Have you tried
composer du?Same here than @LastDragon-ru and @giovannipds This needs a fix.
php artisan package:discoverfails. Any artisan command fail because it loads not existing service provider.That would be nice to add short comment explaining why issue is closed.
I ended up with writing Composer’s
pre-autoload-dumpscript incomposer.jsonfile:@themsaid could you please comment why this was closed?
😱 how do you install dependencies then? pushing the vendor folder?
You can close this issue though since this repo is for bug tracking. You can use the forums or the slack channel
If that’s right, it’d be cool if Laravel News get updated: https://laravel-news.com/laravel-5-4-key-too-long-error since it’s one of the first posts related to
defaultStringLength.@rs-sliske , yes. I think that was the problem. I had a called to
Schemain AppServiceProvider.php. I just used a try-catch in order to solve it.@andreshg112
either your app or a package it is using is trying to access database from a service provider / adding an event listener
personally i recently had this with telescope
Yes we push full vendor folder to git. There are reasons for this.
Should
clear-compiledcommand work to deletebootstrap/cache/packages.php? I thought the purpose of this command is to delete cache frombootstrap/cache. But it fails in my particular case. Ifclear-compiledshould not work in this case I will close issue.