1

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.

cProg
  • 131
  • 1
  • 5
  • Did you read the error messages ? It complains about /usr/local/bin/composer being a directory where it expected a file (or nothing). What is the content of /usr/local/bin/composer ? If it is empty you can try to delete it, – Soren A Apr 20 '21 at 11:28
  • $ ls /usr/local/bin/composer: composer.phar – cProg Apr 20 '21 at 11:34

1 Answers1

2

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
cProg
  • 131
  • 1
  • 5