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

相關內容