gpt4 book ai didi

php - sudo composer install 与 composer install

转载 作者:可可西里 更新时间:2023-11-01 00:40:13 26 4
gpt4 key购买 nike

我运行 sudo composer install 我收到了这个警告

Do not run Composer as root/super user! See https://getcomposer.org/root for details

我只是尝试了 composer install 我得到了这个错误

[ErrorException] file_put_contents(/Applications/MAMP/htdocs/code/bheng/vendor/composer/installed.json): faile d to open stream: Permission denied

这是我的 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

这是我的 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"
}
}

我该如何解决这个问题?我需要 chmod 任何文件夹吗?

最佳答案

删除您的供应商目录并再次运行 composer install

您收到权限被拒绝的错误,因为 vendor/composer/installed.json 文件是在您运行 sudo composer install 时由 root 用户创建的,所以现在当您运行 composer install 时,您的用户没有权限编辑该文件。

更新:

如果您在实时文档根目录中工作(您不应该 - 阅读 atomic deployment),那么您可以在供应商目录及其内容上尝试 chown 以避免任何停机时间删除并重新运行 composer install:

$ sudo chown -R myuser: vendor/

myuser 替换为您的用户名。

关于php - sudo composer install 与 composer install,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43123427/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com