Ubuntu 18.04:安装作曲家:无法写入文件“/usr/local/bin/composer”

Ubuntu 18.04:安装作曲家:无法写入文件“/usr/local/bin/composer”

我正在尝试使用安装作曲家教程在 Ubuntu 18.04 上。我收到以下错误消息:

$ 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.

感谢您的任何帮助。

答案1

我已经删除/usr/local/bin/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

但是当使用

$ sudo composer

我得到的所有信息均正确,如下所示:

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

为了在不被 sudom 的情况下运行 composer,我做了以下事情:

// Clear cache
composer clearcache
// OR
composer clear-cache

// Completely remove the cache directory
sudo rm -rf ~/.composer

相关内容