You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行Artisan::call('cache:clear')报错:Failed to open stream: No such file or directory

问题描述

更新角色与权限后,执行Artisan::call('cache:clear')清除缓存,已运行以下命令设置目录权限:

sudo chown -R www-data:www-data storage
sudo chown -R www-data:www-data bootstrap/cache

但运行缓存清除命令时,出现Failed to open stream: No such file or directory错误,运行环境为Linux+Apache,具体报错信息:

file_put_contents(/var/www/spectse.net/storage/framework/cache/data/14/b1/14b1c21890886e6351e48c7d34e61b418ee3b327): Failed to open stream: No such file or directory {"view":{"view":"/var/www/spectse.net.net/resources/views/components/setting-sidebar.blade.php","data":[]},"userId":7,"exception":"[object] (Spatie\LaravelIgnition\Exceptions\ViewException(code: 0): file_put_contents(/var/www/spectse.net.net/storage/framework/cache/data/14/b1/14b1c21890886e6351e48c7d34e61b418ee3b327): Failed to open stream: No such file or directory at /var/www/spectse.net.net/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:204)

解决步骤

  • 检查并重建缓存目录
    报错路径中的子目录可能未自动创建,手动生成完整结构:

    sudo rm -rf /var/www/spectse.net/storage/framework/cache
    sudo mkdir -p /var/www/spectse.net/storage/framework/cache/data
    
  • 补全目录权限设置
    除了所有者,还要确保目录有读写权限:

    sudo chown -R www-data:www-data /var/www/spectse.net/storage
    sudo chmod -R 775 /var/www/spectse.net/storage
    sudo chown -R www-data:www-data /var/www/spectse.net/bootstrap/cache
    sudo chmod -R 775 /var/www/spectse.net/bootstrap/cache
    
  • 以web用户身份执行Artisan命令
    直接在终端用服务器用户运行缓存清理,避免权限冲突:

    cd /var/www/spectse.net
    sudo -u www-data php artisan cache:clear
    sudo -u www-data php artisan config:clear
    sudo -u www-data php artisan view:clear
    
  • 修正路径拼写错误
    注意报错中出现了重复的.net(路径显示spectse.net.net),确认项目根目录实际名称,修正代码或配置中的路径引用。

内容的提问来源于stack exchange,提问作者Karthik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 23:51:06