简体   繁体   中英

I am trying to install Ruby on Rails and I am getting “`report_activate_error': Could not find RubyGem rails”

What should I do? Here is the error

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:261:in `activate'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:68:in `gem'
    from /usr/bin/rails:18

You're running Mac OS. Apple ships Ruby with Mac OS, though it's there for Apple's own use. We can piggyback on it, but modifying it can cause problems, so we recommend using RVM or rbenv to install one or more Ruby versions in a sandbox, which allows us to update, add, delete gems at will without affecting Apple's Ruby.

  • RVM - very capable, also very confusing to people who don't take the time to read how it works and how to use it. We have more questions about problems with RVM on Stack Overflow for that reason. If you go this route READ THE ENTIRE INSTALLATION PAGE UNTIL YOU UNDERSTAND IT.
  • rbenv - a lighterweight tool similar to RVM, which offers the basics. It supports plugins which provide similar capabilities to what RVM offers.

I use them both, with rbenv being on my personal machine and work laptop.

You can also use Homebrew to install Ruby. It is nice when installing a single version but doesn't provide nearly the features/controls for managing multiple versions. I don't recommend or use it for installing or managing Ruby as a result.

You can also install from the source code. I don't recommend that unless you know what you're doing so that's all I'll say about it.

The OS version you're on is old, and no longer supported by Apple. You can upgrade to a newer Ruby but you'll also need to install your Xcode installation along with its related command-line tools. While RVM might find a prebuilt Ruby to install, any gems that have native extensions will need to be compiled, requiring Xcode, and finding Xcode that supports old OSes might be difficult.

You need an updated version of ruby to install rails:

  1. Get Homebrew (a package manager)
  2. Download the latest version of ruby (not the default mac one) brew install ruby
  3. gem install rails

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM