OsX, can't use Homebrew because of Ruby permission

北城余情 提交于 2020-01-15 09:32:22

问题


I have seen many related questions and posts, but I just can't fix my problems. I am running El Capitan and I want to have Homebrew and Ruby running. But if I want to run Homebrew I get permission errors like:

bio89093:~ jonbra$ brew doctor
/Library/Ruby/Site/2.0.0/rubygems.rb:1219:in `register_default_spec': undefined method `default_gems_use_full_paths?' for Gem:Module (NoMethodError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:699:in `block in load_defaults'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:647:in `block (2 levels) in each_spec'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:643:in `each'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:643:in `block in each_spec'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:642:in `each'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:642:in `each_spec'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:653:in `each_default'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:698:in `load_defaults'
    from /Library/Ruby/Site/2.0.0/rubygems.rb:1361:in `<top (required)>'
    from <internal:gem_prelude>:1:in `require'
    from <internal:gem_prelude>:1:in `<compiled>'

I have tried installing a separate version of Ruby using RVM, but it seems to require Homebrew...


回答1:


Try removing and installing homebrew again:

to uninstall:

$ cd `brew --prefix`
$ rm -rf Cellar
$ brew prune
$ rm -rf Library .git .gitignore bin/brew README.md share/man/man1/brew
$ rm -rf ~/Library/Caches/Homebrew

and then:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"



回答2:


I had a similar issue. Try this in your terminal:

cd "$(brew --repo)" && git fetch && git reset --hard origin/master && brew update

They have a note at the top of the brew github page and following those instructions resolved my issue.




回答3:


Make sure that below folder contains no extra files and folders,

/Library/Ruby/Site/2.0.0

To do so, Please run,

$cd /Library/Ruby/Site/2.0.0
$rm -rf /Library/Ruby/Site/2.0.0/*
$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Sometime you might get SSL error, in that case add -k option in curl.

$/usr/bin/ruby -e "$(curl -k -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


来源:https://stackoverflow.com/questions/40927546/osx-cant-use-homebrew-because-of-ruby-permission

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!