php 须藤作曲家安装与作曲家安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43123427/
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
sudo composer install vs. composer install
提问by cyber8200
I run sudo composer install
I got this warning
我跑sudo composer install
我收到这个警告
Do not run Composer as root/super user! See https://getcomposer.org/rootfor details
不要以 root/超级用户身份运行 Composer!有关详细信息,请参阅https://getcomposer.org/root
I tried just composer install
I got this error
我试过只是composer install
我得到了这个错误
[ErrorException]file_put_contents(/Applications/MAMP/htdocs/code/bheng/vendor/composer/installed.json): faile d to open stream: Permission denied
[ErrorException]file_put_contents(/Applications/MAMP/htdocs/code/bheng/vendor/composer/installed.json):打开流失败:权限被拒绝
Here is the current permission set on my Laravel folder
这是对我的 Laravel 文件夹设置的当前权限
total 1872
-rw-r--r-- 1 bheng staff 777 Feb 27 20:18 phpunit.xml
-rw-r--r-- 1 bheng staff 87 Feb 27 20:18 phpspec.yml
-rw-r--r-- 1 bheng staff 481 Feb 27 20:18 package.json
drwxr-xr-x 3 bheng staff 102 Feb 27 20:18 note
-rw-r--r-- 1 bheng staff 967 Feb 27 20:18 md-bheng-readme.txt
-rw-r--r-- 1 bheng staff 503 Feb 27 20:18 gulpfile.js
-rw-r--r-- 1 bheng staff 26 Feb 27 20:18 contributors.txt
-rw-r--r-- 1 bheng staff 1635 Feb 27 20:18 artisan
-rw-r--r-- 1 bheng staff 43 Feb 27 20:18 Procfile
-rw-r--r-- 1 bheng staff 5634 Feb 27 20:18 Gruntfile.js
drwxr-xr-x 4 bheng staff 136 Feb 27 20:18 tests
drwxr-xr-x 5 bheng staff 170 Feb 27 20:18 storage
drwxr-xr-x 4 bheng staff 136 Feb 27 20:18 sql
-rw-r--r-- 1 bheng staff 560 Feb 27 20:18 server.php
drwxr-xr-x 5 bheng staff 170 Feb 27 20:18 resources
-rw-r--r-- 1 bheng staff 105 Feb 27 20:18 pull.sh
drwxr-xr-x 7 bheng staff 238 Mar 1 14:46 bootstrap
-rw-r--r--@ 1 bheng staff 0 Mar 1 14:46 Icon?
drwxr-xr-x 22 bheng staff 748 Mar 2 11:47 app
drwxrwxrwx@ 27 bheng staff 918 Mar 3 14:55 public
drwxr-xr-x 8 bheng staff 272 Mar 6 13:25 database
-rw-------@ 1 bheng staff 405 Mar 14 09:29 id_rsa.pub
-rw------- 1 bheng staff 1766 Mar 14 09:29 id_rsa
-rw-r--r-- 1 bheng staff 126713 Mar 14 10:00 composer.lock
drwxr-xr-x 18 bheng staff 612 Mar 28 21:24 config
-rw-r--r-- 1 bheng staff 1022 Mar 30 12:21 composer.json
drwxr-xr-x 32 bheng staff 1088 Mar 30 12:21 vendor
Here is what inside my composer.json
这是我的 composer.json 里面的内容
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.1.0",
"intervention/image": "^2.3",
"laravelcollective/remote": "5.1.*",
"doctrine/dbal": "^2.3",
"league/flysystem-sftp": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [ "database" ],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
How do I fix this ? Do I need to chmod any folders ?
我该如何解决 ?我需要修改任何文件夹吗?
回答by Andy
Delete your vendor directory and run composer install
again.
删除您的供应商目录并composer install
再次运行。
You're getting the permission denied error because the file was created by root when you ran sudo composer install
, so now when you run composer install
your user doesn't have permission to edit that file.
您收到权限被拒绝错误,因为该文件是在您运行时由 root 创建的sudo composer install
,所以现在当您运行时,composer install
您的用户没有编辑该文件的权限。
Update:
更新:
If you are working within a live document root (you shouldn't be - read up on atomic deployment) then you can try chown
on the vendor directory and its contents to avoid any downtime between the deletion and re-running composer install
:
如果您在实时文档根目录中工作(您不应该阅读原子部署),那么您可以尝试chown
使用供应商目录及其内容,以避免在删除和重新运行之间出现任何停机时间composer install
:
$ sudo chown -R myuser: vendor/
Replace myuser
with your username.
替换myuser
为您的用户名。