Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error of "error: could not lock config file .git/config: Permission denied" occurs while installing Carthage

I want to install carthage on my Mac OS using brew install carthage command. However, I get the following error:

touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied touch: /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask/.git/FETCH_HEAD: Permission denied touch: /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/.git/FETCH_HEAD: Permission denied touch: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/FETCH_HEAD: Permission denied fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied error: could not lock config file .git/config: Permission denied Warning: carthage 0.26.2 is already installed, it's just not linked. You can use `brew link carthage` to link this version. 

I also get the following error when I used sudo brew install carthage:

Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system. 

Can you let me know what is the problem. Thanks in advance.

like image 639
Reza Avatar asked Mar 14 '18 15:03

Reza


1 Answers

Check for the permissions on these files.

ls -l /usr/local/Homebrew/.git/FETCH_HEAD ls -l /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask/.git/FETCH_HEAD ls -l /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/.git/FETCH_HEAD ls -l /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/FETCH_HEAD 

If you don't have the permissions, run

sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/* 

In High Sierra and above, Run this command instead:

sudo chown -R $(whoami) $(brew --prefix)/* 

You can also see the related github issues here

like image 128
Kazunori Takaishi Avatar answered Oct 01 '22 10:10

Kazunori Takaishi