Ubuntu 18.04: installing composer: Could not write to file "/usr/local/bin/composer"

I'm trying to install composer using a tutorial, on Ubuntu 18.04. I'm having the following error message:

$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
[sudo] password :
All settings correct for using Composer
Downloading...
Could not write to file "/usr/local/bin/composer": rename(/usr/local/bin/composer-temp.phar,/usr/local/bin/composer): Is a directory
Retrying...
Could not write to file "/usr/local/bin/composer": rename(/usr/local/bin/composer-temp.phar,/usr/local/bin/composer): Is a directory
Retrying...
Could not write to file "/usr/local/bin/composer": rename(/usr/local/bin/composer-temp.phar,/usr/local/bin/composer): Is a directory
The download failed repeatedly, aborting.

Thank you for any help.

2

1 Answer

I have deleted /usr/local/bin/composer and started the installation process from the begining and it worked now.

When I enter the following command, I'm getting the following error message:

$ composer

In JsonFile.php line 98: Could not read /home/tonguim/.composer/config.json file_get_contents(/home/tonguim/.composer/config.json): failed to open stre am: Permission denied

But when using

$ sudo composer

I'm getting everything right as follow:

 ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/
Composer version 2.0.12 2021-04-01 10:14:59

To run composer without being sudom I did the following:

// Clear cache
composer clearcache
// OR
composer clear-cache
// Completely remove the cache directory
sudo rm -rf ~/.composer

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like