読者です 読者をやめる 読者になる 読者になる

もた日記

くだらないことを真面目にやる

brew updateでPermission deniedでエラーになる

Mac

Neovimをインストールしようとしてbrew installしたらエラーになり失敗した。

$ brew install neovim/neovim/neovim
Cloning into '/usr/local/Library/Taps/neovim/homebrew-neovim'...
remote: Counting objects: 370, done.
remote: Total 370 (delta 0), reused 0 (delta 0), pack-reused 370
Receiving objects: 100% (370/370), 63.26 KiB | 0 bytes/s, done.
Resolving deltas: 100% (146/146), done.
Checking connectivity... done.
Tapped 1 formula
Error: undefined method `desc' for Formulary::Formulae::Neovim:Class
Please report this bug:
    http://git.io/brew-troubleshooting
/usr/local/Library/Taps/neovim/homebrew-neovim/Formula/neovim.rb:2:in `<class:Neovim>'
/usr/local/Library/Taps/neovim/homebrew-neovim/Formula/neovim.rb:1:in `load_file'
/usr/local/Library/Homebrew/formulary.rb:92:in `module_eval'
/usr/local/Library/Homebrew/formulary.rb:92:in `load_file'
/usr/local/Library/Homebrew/formulary.rb:82:in `klass'
/usr/local/Library/Homebrew/formulary.rb:71:in `get_formula'
/usr/local/Library/Homebrew/formulary.rb:177:in `get_formula'
/usr/local/Library/Homebrew/formulary.rb:200:in `factory'
/usr/local/Library/Homebrew/extend/ARGV.rb:16:in `block in formulae'
/usr/local/Library/Homebrew/extend/ARGV.rb:16:in `map'
/usr/local/Library/Homebrew/extend/ARGV.rb:16:in `formulae'
/usr/local/Library/Homebrew/cmd/install.rb:46:in `install'
/usr/local/Library/brew.rb:135:in `<main>'

調べてみるとbrew updateするとよいらしい。

$ brew update
warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied
fatal: cannot create directory at '.github': Permission denied
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

が、Permission deniedになりbrew updateもエラーになった。
下記リンクを参考にコマンドを実行して修正。

qiita.com

$ cd $(brew --prefix)
$ sudo chown -R $USER $(brew --prefix)
$ git fetch --all
$ git reset --hard origin/master

無事に動くようになった。

$ brew update
To restore the stashed changes to /usr/local run:
  'cd /usr/local && git stash pop'
Already up-to-date.