未找到命令

如果我输入“作曲家”我得到上述错误消息。

我在我的苹果笔记本电脑上写道:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

在全球范围内安装 Composer。

我必须手动创建/local/bin/writer 目录,这可能会导致错误?

php composer.phar

如果 i 在. phar 文件所在的代码目录中就可以工作。

我能做些什么来解决这个问题,并将作曲家全球化?

我的个人资料

export PS1="\W: "
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx

~ : Echo $PATH

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/bin
~:
160437 次浏览

The path /usr/local/bin/composer is not in your PATH, executables in that folder won't be found.

Delete the folder /usr/local/bin/composer, then run

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

This moves composer.phar into /usr/local/bin/ and renames it into composer (which is still an executable, not a folder).

Then just use it like:

$ composer ...

I get into the same issue even after moving the composer.phar to '/usr/local/bin/composer' using the following command in amazon linux.

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

I used the following command to create a alias for the composer file. So now its running globally.

alias composer='/usr/local/bin/composer'

I don't know whether this will work in OS-X. But when i search with this issue i get this link. So I'm just posting here. Hope this will help someone.

This works on Ubuntu;

alias composer='/usr/local/bin/composer/composer.phar'

On Mac OS X, for anyone having:

-bash: /usr/local/bin/composer: Permission denied

problem, while trying to move downloaded composer.phar using:

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

this is the cause:

System Integrity Protection

and this is the solution:

  1. Reboot in recovery mode: restart you mac and hold down cmd+R.
  2. Open the terminal once recovery mode has started via Utilities>Terminal via the bar at the top.
  3. Type in csrutil disable and hit enter. You should see a msg returned saying that:

    the System Integrity Protection is off.

  4. Restart the computer as normal and then go set up composer. I had to put it in /usr/bin and NOT /usr/local/bin because for some reason it just didn't work there.
  5. Go back to recovery mode and enable System Integrity Protector by typing csrutil enable
  6. Come back in normal boot up and check that composer works. It did for me.

The above 6 steps are copied from here, so all the credit belongs to the user Vasheer there.

Tested on Mac OSX after installing via instructions on composer website:

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

Globally install Composer on OS X 10.11 El Capitan

This command will NOT work in OS X 10.11:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer

Instead, let's write to the /usr/local/bin path for the user:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Now we can access the composer command globally, just like before.

Well I tried a lot of things but none seemed to be working. But the following process did it right, I can now use composer command in terminal. I'm in mac OS 10.12.1

$ curl -sS https://getcomposer.org/installer | php
$ chmod +x composer.phar
$ mv composer.phar /usr/local/bin/composer
$ composer

this wasted me a day or two. like why dont anybody say on tutorials that the command composer is not to be used without actually linking and stuff... I mean everyone is writing composer command like its the next step when we are not all 5 years experienced users to know these details.

cp composer.phar /usr/local/bin/composer

did it for me on ubuntu after getting stuck for 2 days

If you have to run composer with sudo, you should change the directory of composer to

/usr/bin

this was tested on Centos8.

Composer is avialble and install the packages in the global path but they are not available in the shell, Mac in my case. I managed to fix this by adding the global bin to the path at my bash file.

Steps:

First, check what is your home directory by typing in the shell:

cd ~
pwd

this will tell you the home path

The next step is to verify that composer set the global directory there:

ls -al .composer

If you got list of files that's mean composer set up the directory, if not - look above or in the documentation.

The next step is to edit the bash profile. Mine is ~/.bash_profile but other can ~/.zshrc. If you don't have any one like this try to see how to set up aliases and place the the code in aliases file:

PATH="YOUR_HOME_PATH/.composer/vendor/bin:${PATH}"
export PATH

That's it! just reload the file with

source PATH_TO_FILE

And you good to go!

This worked fine for me this time in the permissions issue.

alias composer="php /usr/local/bin/composer/composer.phar"