作曲家更新时出现 RuntimeException

RuntimeException on a composer update

当我对现有项目进行作曲家更新时,我遇到了这个 RuntimeException:

Could not delete /home/deepak/formation_symfony_4/SF4C4_hangman_begin/hangman/vendor/symfony/contracts/LICENSE

所以,肯定是权限问题。我在供应商文件夹上执行了 ls -al,结果如下:

total 104
drwxr-xr-x 25 root root 4096  3 août  00:27 .
drwxr-xr-x 14 root root 4096  3 août  00:27 ..
-rwxr-xr-x  1 root root  178  3 août  00:27 autoload.php
drwxr-xr-x  2 root root 4096  3 août  00:27 bin
drwxr-xr-x  2 root root 4096  3 août  00:27 composer
drwxr-xr-x 18 root root 4096  3 août  00:27 doctrine
drwxr-xr-x  3 root root 4096  3 août  00:27 easycorp
drwxr-xr-x  3 root root 4096  3 août  00:27 egulias
drwxr-xr-x  3 root root 4096  3 août  00:27 jdorn
drwxr-xr-x  3 root root 4096  3 août  00:27 monolog
drwxr-xr-x  3 root root 4096  3 août  00:27 myclabs
drwxr-xr-x  3 root root 4096  3 août  00:27 nikic
drwxr-xr-x  4 root root 4096  3 août  00:27 ocramius
drwxr-xr-x  4 root root 4096  3 août  00:27 phar-io
drwxr-xr-x  5 root root 4096  3 août  00:27 phpdocumentor
drwxr-xr-x  3 root root 4096  3 août  00:27 phpspec
drwxr-xr-x  8 root root 4096  3 août  00:27 phpunit
drwxr-xr-x  6 root root 4096  3 août  00:27 psr
drwxr-xr-x 13 root root 4096  3 août  00:27 sebastian
drwxr-xr-x  3 root root 4096  3 août  00:27 sensio
drwxr-xr-x  3 root root 4096  3 août  00:27 swiftmailer
drwxr-xr-x 55 root root 4096  3 août  00:27 symfony
drwxr-xr-x  3 root root 4096  3 août  00:27 theseer
drwxr-xr-x  3 root root 4096  3 août  00:27 twig
drwxr-xr-x  3 root root 4096  3 août  00:27 webmozart
drwxr-xr-x  4 root root 4096  3 août  00:27 zendframework

我该如何解决这个问题?

您的 vendor 目录归 root 所有,因此您有三个选择:

运行 composer 作为 root.

作曲家 运行 具有更高的权限,不必要。这不是好的做法。

使 vendor 对任何人都可写:

sudo chmod -R o+w vendor

任何人都可以修改 vendor 内容,这些内容大概是 运行 自动进行的,无需过多审查。同样,糟糕的安全实践。

vendor 的所有权更改为您想要 运行 composer 的用户:

sudo chown -R <user:group> vendor