OSX -bash: composer: command not found
Solution 1
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 ...
Solution 2
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
Solution 3
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.
Solution 4
Tested on Mac OSX after installing via instructions on composer website:
sudo mv composer.phar /usr/local/bin/composer
Solution 5
This works on Ubuntu;
alias composer='/usr/local/bin/composer/composer.phar'
Related videos on Youtube
bobbybackblech
Updated on July 08, 2022Comments
-
bobbybackblech almost 2 years
If i type "composer" i get the above error message.
I did on my macbook:
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
to install Composer globally.
I had to manually create the /local/bin/composer directory, maybe this caused the error ?
php composer.phar
works if i in my code directory where the .phar file is.
What could i do to solve the problem and run composer globally ?
My ~/.profile
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 ~:
-
Droppy almost 10 years
chmod 0755 /usr/local/bin/composer
and add/usr/local/bin
to$PATH
in~/.bash_profile
. This is basic user stuff and does not belong here. -
bobbybackblech almost 10 yearsWhat exactly should i add to my .profile ? I updated my post with the content of my .profile
-
Gromski almost 10 yearsSo composer is now at
/usr/local/bin/composer/composer.phar
? -
Peyman Mohamadpour almost 8 yearsSame problem on mac os x 10.11.4 here with
/usr/local/bin
&/usr/local/bin/composer
in the $PATH, still getting-bash: /usr/local/bin/composer/composer.phar: Permission denied
-
Ashwani Garg over 2 years@Pmpr Have you got any solution for permissions issue?
-
Peyman Mohamadpour over 2 years@AshwaniGarg Sorry, but dont remember that anymore.
-
-
Gromski almost 9 yearsThe fact that you're typing in "$" perhaps? That's just to signify your command line prompt, which typically is "$".
-
Jeroen van Langen almost 9 yearsI'm getting a
composer: Permission denied
saw some solutions withsudo chmod
but i'm gettingsudo: not found
(it's a synology (busybox)) -
JGallardo about 8 yearsMaybe that is why
$
should not be included in answers. Seems obvious to us but not to new people. And it is also obvious that you don't need the$
for people to understand that you are talking about the terminal. -
gvanto about 8 yearsI think including the $ is great (if you have problems understanding what the $ is for hmmm then maybe linux scripting is not for you?)
-
Sanjay over 7 yearsYea it worked after creating alias. alias composer='/usr/local/bin/composer'
-
theprojectabot over 7 yearsYou should chmod +x the binary instead of just turning off your csrutil ...
-
greendino about 4 yearsyou should restart your terminal once you had done this
-
lovecoding almost 4 yearsGreat article! I have been searched a lot for this.
-
Jonas de Herdt almost 4 yearsWhy is this not in the documentation on composer! Ty @deceze
-
Gromski almost 4 years@Jonas The Composer documentation doesn't advise creating any folders, and if you just follow exactly what it says, you won't see this problem at all: getcomposer.org/doc/00-intro.md#globally
-
Saitama almost 4 yearsAfter digging around. This is the only way that works for me on the mac.
-
Dushan over 3 yearsYeah this works. you need to delete "composer" folder at the end of this path
/usr/local/bin/composer
then run the commandmv composer.phar /usr/local/bin/composer
-
James Hubert over 3 yearsIt's helpful to have the $ in stack overflow answers to signify the beginning of the command line.
-
Ashwani Garg over 3 yearsI tried this on MacOS M1, working like charm and saved my lot of time. Thanks for the solution
-
Mohamed23gharbi over 3 years@lone_coder you made my day, in fact I was stuck, and the solution was as simple as just restarting the terminal
-
Michael Falciglia about 3 yearsMe too, followed all the tutorials and they couldn't add one tiny line or two of information about the command being moved to /usr/local/bin/composer. They all say to run something like run "export PATH="$HOME/.composer/vendor/bin:$PATH"" and it does not fix it!
-
Ashwani Garg over 2 yearszsh: permission denied: composer
-
Sean H about 2 yearsI get php: command not found
-
Arslan Ramay about 2 yearsWorks perfect on MacOS Monterey. Thanks!