php Laravel 更新后抛出“引导程序/缓存目录必须存在且可写”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43718391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel throws 'The bootstrap/cache directory must be present and writable' error after update
提问by Peter Bennink
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:
我使用了'composer update',它更新了一些软件包。在更新过程中,网站仍然可以运行。但是,在显示“已删除编译的服务文件”之后,该网站不会加载,而是显示:
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).
最奇怪的是,当我再次运行“composer update”时,网站再次开始工作,直到删除编译的服务文件,此时它再次抛出相同的错误。我已经尝试了出现此错误时应该做的通常的事情(chown -R 将所有内容分别添加到正确的用户/组和 chmod 所有文件和文件夹 664 和 775)。
I don't know what to do anymore, as the error doesn't seem 'correct'..
我不知道该怎么办了,因为错误似乎不“正确”..
回答by Jim Wright
Try this after you have run the composer update:
运行 Composer 更新后试试这个:
php artisan cache:clear
回答by mpalencia
On your Laravel directory file, run:
在 Laravel 目录文件中,运行:
sudo chmod -R 777 bootstrap/cache/
回答by Vinay Vissh
Short version: If uploading using something like AWS eb cliVerify if bootstrap/cachefolder (not talking about its contents) is being deployed.
简短版本:如果使用诸如AWS eb cli 之类的东西上传,请验证是否正在部署引导程序/缓存文件夹(不谈论其内容)。
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.
我正在使用 Amazon Web Services 的 Elastic Beanstalk 来托管我的 Laravel 项目。因为我刚刚开始使用 Laravel,所以我对它的功能不太了解。两天前,我的新部署都因 OP 的错误消息而在中途崩溃。
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 .ebignorefile to not upload the content of /bootstrap/cache(as its content is environment dependent a.k.amy localhost configurations have no meaning on my production server)
And facepalmI did not realise that this will stop the bootstrap/cachefolder 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) .gitkeepfile 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 ~.~ )
缓存配置以加快速度。我在composer.json的“ post-install-cmd”和“ post-update-cmd”子句中添加了相同的内容。
而且我还添加语句.ebignore文件不能上传的内容/引导/缓存(作为其内容是环境依赖又名我的本地配置有我的生产服务器上没有意义),
而捂脸我并没有意识到,这将阻止引导/cache文件夹被上传(像 git 一样,eb cli 忽略空文件夹)。
所以,当我在晚上开始部署时,部署注定要崩溃。
所以,现在我刚刚在bootstrap/cache 中放置了空占位符(比如).gitkeep文件。并且部署再次工作:)
(虽然问题很简单,但我在 ssh-ing 和挖掘 EBS EC2 实例后意识到了一些甜蜜的睡眠时间〜.〜)
回答by Mohit Poddar
The best way to resolve this error is : 1. Open your project folder 2. Move to the bootstrap directory 3. Create an empty folder named as "cache" 4. Then do php artisan cache: clear This will work for sure
解决此错误的最佳方法是: 1. 打开您的项目文件夹 2. 移动到引导目录 3. 创建一个名为“缓存”的空文件夹 4. 然后执行 php artisan cache: clear 这肯定会起作用
回答by Sadegh Ameri
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.
我在 Windows 10 上以非提升模式(非管理员)使用 cmder。命令 php artisan cache:clear 对我不起作用。文件夹引导程序/缓存不存在。我创建了该文件夹并从 bootstrap 和 bootstrap/cache 文件夹中删除了只读。composer install 和 composer update 现在都在工作。
回答by mohamed elshazly
it work for me run in project folder
它对我有用,在项目文件夹中运行
sudo chmod -R 777 bootstrap/cache
than run
比跑
composer update
than run
比跑
cache:clear
回答by Arif.0o7
sudo chmod -R ug+rwx storage bootstrap/cache
hopefully, this will solve the problem.
希望这将解决问题。
回答by Software Developer
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
这将避免弄乱缓存文件的必要性,这可能会导致全新的问题
回答by Waleed Muaz
Try this too after you have run the composer update:
运行 Composer 更新后也试试这个:
php artisan config:clear
回答by Mugoma J. Okomba
If a web server (e.g. Apacheor Nginx) is being used as a front-end the solution is to make the directory bootstrap/cache
owned by web server group. For Nginx:
如果 Web 服务器(例如Apache或Nginx)被用作前端,则解决方案是使目录bootstrap/cache
归 Web 服务器组所有。对于Nginx:
$ sudo chgrp -R nginx bootstrap/cache