简体   繁体   English

正确安装后,无法运行“ sudo作曲家”

[英]Running “sudo composer” won't work after installing properly

I have been trying to install composer on my Mac (running macOS Sierra). 我一直试图在Mac上安装composer(运行macOS Sierra)。 The composer.phar file is now located in /usr/local/bin/composer/ and it works properly when I'm not running composer as a root. 现在,composer.phar文件位于/usr/local/bin/composer/ ,当我没有以root身份运行composer时,它可以正常工作。

$ composer -V
Composer version 1.2.4 2016-12-06 22:00:51

However, when I try to run composer as a root (which of course is required to install dependencies), I get this: 但是,当我尝试以root身份运行composer时(当然需要安装依赖项),我得到以下信息:

$ sudo composer
sudo: composer: command not found

I have no single clue how to fix it, has anyone else had this? 我没有一个如何解决它的线索,其他人有这个吗?

it must be a composer.phar renamed to composer into /usr/local/bin/ , not a directory composer/ 它必须是composer.phar重命名为composer到/ usr / local / bin /,而不是目录composer /

From : https://getcomposer.org/doc/00-intro.md 来自: https : //getcomposer.org/doc/00-intro.md

Globally# 全球范围#

You can place the Composer PHAR anywhere you wish. 您可以将Composer PHAR放置在所需的任何位置。 If you put it in a directory that is part of your PATH, you can access it globally. 如果将其放在PATH的一部分中,则可以全局访问它。 On unixy systems you can even make it executable and invoke it without directly using the php interpreter. 在unixy系统上,您甚至可以使它可执行并调用它,而无需直接使用php解释器。

After running the installer following the Download page instructions you can run this to move composer.phar to a directory that is in your path: 按照“下载”页面上的说明运行安装程序后,可以运行此命令将composer.phar移至路径中的目录:

mv composer.phar /usr/local/bin/composer

Note: If the above fails due to permissions, you may need to run it again with sudo. 注意:如果以上操作由于权限而失败,则可能需要使用sudo重新运行。

Note: On some versions of OSX the /usr directory does not exist by default. 注意:在某些版本的OSX中,默认情况下/ usr目录不存在。 If you receive the error " /usr/local/bin/composer: No such file or directory " then you must create the directory manually before proceeding: 如果收到错误“ / usr / local / bin / composer:无此类文件或目录 ”,则必须在继续之前手动创建目录:

mkdir -p /usr/local/bin

Note: For information on changing your PATH, please read the Wikipedia article and/or use Google. 注意:有关更改PATH的信息,请阅读Wikipedia文章和/或使用Google。 Now just run composer in order to run Composer instead of php composer.phar. 现在只需运行composer即可运行Composer,而不是php composer.phar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM