为什么 Laravel 的 Composer 创建项目执行失败? [英] Why does Composer create-project execution for Laravel fail?

查看:48
本文介绍了为什么 Laravel 的 Composer 创建项目执行失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,除非我使用 sudo,否则我的 composer 命令无法创建 Laravel 项目.

It appears that unless I use sudo my composer command fails to create a Laravel project.

没有 sudo 它会给我以下错误:

Without sudo it gives me the following error:

[ErrorException]                                                             
  copy(/Users/H/.composer/cache/files/laravel/laravel/73094f2633f1b90f3ef  
  6de4a8a5b610532510e0e.zip): failed to open stream: Permission denied  

我在这里错过了什么?

推荐答案

如果你曾经执行过:

sudo composer <anything>

您的一些作曲家主文件 (~/.composer/) 将由 root 编写,如果您无法删除或再次覆盖它们,除非您使用 sudo 成为 root,所以你有 2 个选项:

Some of your composer home files (~/.composer/) will be written by the root and if you can't delete or write over them again unless you use sudo to become root, so you have 2 options:

1) 将这些文件的用户改回您自己的用户:

1) Change the user of those files back to your own:

sudo chown $USER:$USER -R ~/.composer

或者在 Mac 上

sudo chown -R $USER:staff ~/.composer

2) 删除整个文件夹(并丢失缓存)以从头开始:

2) Delete the whole folder (and lose your cache) to restart from scratch:

sudo rm -rf ~/.composer/cache

甚至

sudo rm -rf ~/.composer

这篇关于为什么 Laravel 的 Composer 创建项目执行失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆