Reputation: 973
I used 'composer update', which updated a few packages. During the updating process the website still functions. However, after it says 'The compiled services file has been removed', the website doesn't load and instead says:
Exception in ProviderRepository.php line 190:
The bootstrap/cache directory must be present and writable.
The weirdest thing is, when I run 'composer update' again, the website starts to work again, until the compiled services file is removed, at which point it throws the same error again. I have already tried the usual things that should be done when this error appears (chown -R everything to the right user/group and chmod all the files and folders 664 and 775 respectively).
I don't know what to do anymore, as the error doesn't seem 'correct'..
Upvotes: 97
Views: 200204
Reputation: 239
The best way to resolve this error is:
bootstrap
directorycache
php artisan cache:clear
This will work for sure
Upvotes: 20
Reputation: 5997
On your Laravel directory file, run:
sudo chmod -R 775 bootstrap/cache/
Upvotes: 39
Reputation: 505
If if the top answers fail, then do the following;
//cd to your project directory (or just before it), then
sudo chown -Rv root:$USER .
sudo chmod -Rv g+rw .
This will give proper rights to the current user (which is recommended NOT to be root while executing composer).
Upvotes: 1
Reputation: 327
OS: Linux Ubuntu
If you are using Docker, maybe try this:
services:
php:
restart: always
container_name: app-php
user: 'www-data:www-data'
volumes:
- ./:/var/www/html # synchronous
And Open Terminal
sudo chown -R $USER:$USER <your_project>
Now try this:
docker exec -it <your_container_name> /bin/bash
chown -R www-data:www-data bootstrap/
chown -R www-data:www-data storage/
ls -l # You are see folders/files USER/GROUP
php artisan cache:clear # success
php artisan route:clear # success
composer dump-autoload # success
Upvotes: 0
Reputation: 1202
In my case, I've found out that the bootstrap/cache
is missing in my project during a fresh clone.
Re-adding the cache directory manually solved my issue.
Then running composer install
now works fine.
Upvotes: 1
Reputation: 116
I had to create these five folders to be able to run artisan again.
mkdir bootstrap/cache
mkdir storage/framework
mkdir storage/framework/cache
mkdir storage/framework/views
mkdir storage/framework/sessions
Answer was found in this related question: "Please provide a valid cache path" error in laravel
Upvotes: 1
Reputation: 59
Simple. There are applications that can block the directory. Like google drive synchronizer, One driver synchronizer, or any other application that is using windows explorer.
Delete cache folder. Create this again.
Upvotes: 2
Reputation: 2964
bootstrap/cache
dir is exist if not create a new one
mkdir -p bootstrap/cache/
php artisan config:cache
Upvotes: 4
Reputation: 4141
I don't imagine what I got done wrong with that before and no games around with that cashclearings had sense. But as it claims there was no 'cache' folder inside /bootstrapp . Had to have create it manually. Now it all rocks ok again
Upvotes: 0
Reputation: 802
Try this too after you have run the composer update:
php artisan config:clear
Upvotes: 6
Reputation: 868
Try executing the following commands in your project root directory
composer update
then do
composer dumpautoload
this will avoid the necessity of messing with cache files which may lead to whole new sort of issues
Upvotes: 0
Reputation: 61
sudo chmod -R ug+rwx storage bootstrap/cache
hopefully, this will solve the problem.
Upvotes: 3
Reputation: 548
it work for me run in project folder
sudo chmod -R 777 bootstrap/cache
than run
composer update
than run
cache:clear
Upvotes: 1
Reputation: 310
Im using cmder on windows 10 in non elevated mode (Non-Admin). command php artisan cache:clear did not work for me. The folder bootstrap/cache did not exist. I created the folder and removed readonly from both bootstrap and bootstrap/cache folder. Both composer install and composer update are working now.
Upvotes: 3
Reputation: 3295
If a web server (e.g. Apache or Nginx) is being used as a front-end the solution is to make the directory bootstrap/cache
owned by web server group. For Nginx:
$ sudo chgrp -R nginx bootstrap/cache
Upvotes: -1
Reputation: 477
Short version: If uploading using something like AWS eb cli Verify if bootstrap/cache folder (not talking about its contents) is being deployed.
Some background behind my answer
I am using Amazon Web Services' Elastic Beanstalk to host my Laravel project. As I just started using Laravel I do not have much idea about its functioning. Two days back My new deployments were all crashing midway with OP's error message.
Earlier that day, I realised that I was not using
php artisan config:cache
to cache configurations to make things faster. And I added the same in composer.json's "post-install-cmd" and "post-update-cmd" clauses.
And I also added statement in .ebignore file to not upload the content of /bootstrap/cache (as its content is environment dependent a.k.a my localhost configurations have no meaning on my production server)
And facepalm I did not realise that this will stop the bootstrap/cache folder from being uploaded (as Like git, eb cli ignores empty folders).
So, when I started to deploy at night The deployments were meant to crash.
So, now I have just placed empty-placeholder (say) .gitkeep file in bootstrap/cache. And deployments are working once again :)
(Though the problem was so simple I realised the reason after ssh-ing and digging an EBS EC2 instance for some sweet sleep hours ~.~ )
Upvotes: 8
Reputation: 2664
Try this after you have run the composer update:
php artisan cache:clear
Upvotes: 252