Laravel throws 'The bootstrap/cache directory must be present and writable' error after update

后端 未结 12 671
礼貌的吻别
礼貌的吻别 2020-12-14 14:03

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 be

相关标签:
12条回答
  • 2020-12-14 14:30

    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

    0 讨论(0)
  • 2020-12-14 14:31

    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 ~.~ )

    0 讨论(0)
  • 2020-12-14 14:32
    sudo chmod -R ug+rwx storage bootstrap/cache
    

    hopefully, this will solve the problem.

    0 讨论(0)
  • 2020-12-14 14:32

    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
    
    0 讨论(0)
  • 2020-12-14 14:33

    For me, I manually created the cache folder inside bootstrap.

    0 讨论(0)
  • 2020-12-14 14:39

    On your Laravel directory file, run:

    sudo chmod -R 777 bootstrap/cache/
    
    0 讨论(0)
提交回复
热议问题