沃梦达 / 编程问答 / php问题 / 正文

作曲家:file_put_contents(./composer.json):无法打开流:权限被拒绝

Composer: file_put_contents(./composer.json): failed to open stream: Permission denied(作曲家:file_put_contents(./composer.json):无法打开流:权限被拒绝)

本文介绍了作曲家:file_put_contents(./composer.json):无法打开流:权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Prestissimo 安装到 Ubuntu 16.04 服务器,但这会导致错误:

I'm trying to install Prestissimo to an Ubuntu 16.04 server, but that leads to an error:

$ composer global require "hirak/prestissimo:^0.3"
Changed current directory to /home/kramer65/.composer


  [ErrorException]
  file_put_contents(./composer.json): failed to open stream: Permission denied


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

我以用户 kramer65 的身份登录,所以我不知道为什么它不能写入我的主文件夹.我对 permission denied 的正常反应是使用 sudo,但 composer 总是说:

I'm logged in as user kramer65, so I wouldn't know why it can't write to my home folder. My normal reaction to a permission denied is to use sudo, but composer then always says:

不要以 root/超级用户身份运行 Composer!详见https://getcomposer.org/root

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

知道如何解决这个问题吗?

Any idea how I can solve this?

推荐答案

我在安装 laravel/lumen 时遇到了这个问题.

I had this problem to install laravel/lumen.

可以通过以下命令解决:

It can be resolved with the following command:

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

这篇关于作曲家:file_put_contents(./composer.json):无法打开流:权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:作曲家:file_put_contents(./composer.json):无法打开流:权限被拒绝

基础教程推荐