This is going to be easy one I guess. On my OS X - Yosemite I have copied composer.phar to my /usr/bin
directory. I have been using it for a while but today I needed to run "composer update
". It didnt work of course so I ran "sudo composer update
". Then I got the message "command composer not found". Chmm
I copied composer to /usr/local/bin
according to the documentation and now "sudo composer
" works like charm. BUT when I run "composer
" without sudo, it still uses the old one in "/usr/bin
" directory. So I deleted it.
Now composer works only with sudo command. I get "Could not open input file: /usr/bin/composer.phar" otherwise. What should I do to point command "composer
" to the new location in /usr/local/bin
?
Another alternative to get a nice composer command instead of composer.phar:
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin
$ ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
Edit:
/etc/bashrc
Add this to that file:
alias composer="php /usr/local/bin/composer"
run:
source /etc/bashrc
Composer should now run without sudo.
Okay, I encountered issues of having to run composer commands with sudo
as well, but in order to get it working without throwing this kind of error (in Ubuntu 15.10):
[ErrorException]
copy(/home/randomuser/.composer/cache/files/barryvdh/laravel-cors/056068736ff8f002514178e1416c7665732eaddc.zip): failed to open stream: Permission denied
What simply solved the issue for me is:
$ cd
sudo chown -R $USER:$USER .composer/
composer install
works smoothly.PS: this might be different for other situation.
Hope this helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With