“无法创建缓存目录 /home//.composer/cache/repo/https---packagist.org/,或目录不可写。继续执行,无需缓存”

“无法创建缓存目录 /home//.composer/cache/repo/https---packagist.org/,或目录不可写。继续执行,无需缓存”

我是新手。

我尝试在我的 Ubuntu 中安装 MISP,按照以下安装指南进行操作:安装.ubuntu1804.txt

当谈到这个指令时:

# Once done, install CakeResque along with its dependencies if you intend to use the built in background jobs:
cd /var/www/MISP/app
sudo -u www-data php composer.phar require kamisama/cake-resque:4.1.2

我懂了:

Cannot create cache directory /home/akatiubuntutest/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/akatiubuntutest/.composer/cache/files/, or directory is not writable. Proceeding without cache
./composer.json has been updated
Cannot create cache directory /home/akatiubuntutest/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/akatiubuntutest/.composer/cache/files/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing monolog/monolog (1.23.0)
    Downloading: 65%^C        

我尝试过这里的解决方案无法创建缓存目录!请帮我在使用 Composer 创建 Laravel 项目时解决这个问题

sudo chown -R <user> /home/<user>/.composer/cache/repo/https---packagist.org

但是(嗯,从逻辑上讲,因为它尚未被创建)我得到了这个:

chown: cannot access '/home/<user>/.composer/cache/repo/https---packagist.org/': No such file or directory

我已经安装了 PHP 及其依赖项:

# Install PHP and dependencies
sudo apt-get install libapache2-mod-php php php-cli php-gnupg php-dev php-json php-mysql php-opcache php-readline php-redis php-xml php-mbstring

现在,我不确定我错过了什么。

答案1

如果有人经过这里,这是更短的解决方案:

sudo chown -R $USER $HOME/.composer

答案2

我觉得你的命令中缺少组信息

sudo chown -R <user> /home/<user>/.composer/cache/repo/https---packagist.org

应该是

sudo chown -R <user>:<group> /home/<user>/.composer/cache/repo/https---packagist.org

但为了避免其他权限问题,我建议:

sudo chown -R <user>:<group> /home/<user>/.composer/cache

(你需要访问其中的其他文件夹)和

sudo chown <user>:<group> /home/<user>/.composer

确保您的用户对全局 composer 文件夹具有足够的权限。请注意缺少递归,以便用户不拥有 root 创建的密钥。如果您需要找出组:

groups <user>

相关内容