Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Something wrong with my ruby

Always the same error:


AilixdeMacBook-Pro:~ Ailix$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
AilixdeMacBook-Pro:~ Ailix$ ruby -d
Exception `LoadError' at /Library/Ruby/Site/2.0.0/rubygems.rb:1240 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Library/Ruby/Site/2.0.0/rubygems.rb:1249 - cannot load such file -- rubygems/defaults/ruby
Exception `NameError' at /Library/Ruby/Site/2.0.0/rubygems.rb:1257 - uninitialized constant Gem::Specification
/Library/Ruby/Site/2.0.0/rubygems.rb:1257:in `': uninitialized constant Gem::Specification (NameError)
    from :1:in `require'
    from :1:in `'
AilixdeMacBook-Pro:~ Ailix$ gem -v
/Library/Ruby/Site/2.0.0/rubygems.rb:1257:in `': uninitialized constant Gem::Specification (NameError)
    from :1:in `require'
    from :1:in `'
AilixdeMacBook-Pro:~ Ailix$ brew -v
/Library/Ruby/Site/2.0.0/rubygems.rb:1257:in `': uninitialized constant Gem::Specification (NameError)
    from :1:in `require'
    from :1:in `'
AilixdeMacBook-Pro:~ Ailix$ pod repo
/Library/Ruby/Site/2.0.0/rubygems.rb:1257:in `': uninitialized constant Gem::Specification (NameError)
    from :1:in `require'
    from :1:in `'

I guess something wrong with my ruby. But i don't know how to fix it

My environment:

MacOS 10.10.5
Xcode 7.2

Thanks in advance

like image 236
Ailix Avatar asked Feb 06 '16 11:02

Ailix


1 Answers

The system ruby installation seems to be messed up. Try removing the offending /Library/Ruby/Site/2.0.0/rubygems.rb (and may be more of enclosing folders)

Ruby have its bundled rubygems at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0 so it should work with these.

Once ruby is alive - you can try upgrading rubygems again by sudo gem update --system if needed, but I advise setting up a ruby version manager like rvm (rvm.io) and leave the system ruby be there only for emergences and backing the brew.

like image 152
Vasfed Avatar answered Sep 22 '22 10:09

Vasfed