安装Carthage时出现“错误:无法锁定配置文件.git / config:权限被拒绝”的错误

时间:2018-03-14 15:40:37

标签: macos homebrew carthage

我想使用brew install carthage命令在我的Mac OS上安装carthage。但是,我收到以下错误:

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.

当我使用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.

你能告诉我这是什么问题。提前致谢。

6 个答案:

答案 0 :(得分:49)

在High Sierra中,运行命令:

SELECT * 
       ,BothXml.query(N'for $p1 in distinct-values(/persons[1]/root[1]/Person/text())
                              for $p2 in distinct-values(/persons[1]/root[2]/Person[text()=$p1]/text())
                              return $p2    
                       ') AS CommonIDs
FROM @tbl t
CROSS APPLY(SELECT t.Xml1 AS [*],t.Xml2 AS [*] FOR XML PATH('persons'),TYPE) A(BothXml);

答案 1 :(得分:20)

检查这些文件的权限。

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

如果您没有权限,请运行

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

在High Sierra中,改为运行此命令:

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

您还可以查看相关的github问题here

答案 2 :(得分:1)

几个小时后(像往常一样),我安装了macOS Catalina 10.15.1。

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

答案 3 :(得分:0)

我有High Sierra,只有这对我有用。  

1. sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/*
you should not write sudo before brew the right command is 
2. brew install mysql

答案 4 :(得分:0)

您也可以使用它 sudo chown -R $USER $(brew --prefix)/*

答案 5 :(得分:0)

这对我有用: MacOS 10.15.1 sudo chown -R $ {whoami):admin / usr / local / * && sudo chmod -R g + rwx / usr / local / *

相关问题