使用 Laravel 拒绝 .composer/config 文件权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34511744/
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
.composer/config file permission denied using laravel
提问by user3494047
I have a laravel project on an ubuntu virtualbox.
I used to run composer update
and all worked fine. I don't know of any changes that could have affected this but now when I run composer update
I get
我在 ubuntu 虚拟机上有一个 Laravel 项目。我曾经跑步composer update
,一切正常。我不知道任何可能会影响到这一点的变化,但现在当我跑步时composer update
我得到
file_get_contents(/home/user/.composer/config.json): failed to open stream:
Permission denied
file_get_contents(/home/user/.composer/config.json): failed to open stream:
Permission denied
Does anyone know why? When I run sudo composer update
, it works.
有谁知道为什么?当我运行时sudo composer update
,它起作用了。
回答by Bogdan
Your permissions got changed somehow (perhaps not related with running composer
). Setting the owner of that file as your user should fix the issue:
您的权限以某种方式发生了变化(可能与 running 无关composer
)。将该文件的所有者设置为您的用户应该可以解决问题:
sudo chown user /home/user/.composer/config.json
The above assumes that the username is user
from the home path. As a side note, it works when running it as a super user using sudo
because there's no permissions restrictions in that case.
以上假设用户名user
来自主路径。作为旁注,它在以超级用户身份运行时有效,sudo
因为在这种情况下没有权限限制。
回答by Marcin Nabia?ek
It seems you don't have valid permissions for this file. Try running:
您似乎没有此文件的有效权限。尝试运行:
sudo chmod 0777 /home/user/.composer/config.json
EDIT
编辑
Of course, you should do it only in development environment (you mentioned you use Virtualbox). You should not do it in production environment.
当然,您应该只在开发环境中执行此操作(您提到您使用 Virtualbox)。你不应该在生产环境中这样做。
回答by Marcin Nabia?ek
Run below command.
运行下面的命令。
sudo composer update