简体   繁体   中英

Trying to install rails in terminal, not sure what error means

I'm getting this when trying to install rails using: gen install rails I barely have any idea what I'm doing :/ Trying to learn :)

ERROR:  Error installing rails:
ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.7.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.5/ext/json/ext/generator/gem_make.out

Thanks in advance!

I've tried following directions here (http://rubyonrails.org/download) and here (http://rubygems.org/pages/download).

I'm going to assume that you're new to Ruby as well, just in case doing so can help others who need this answered. Please don't take offense.

It looks like your installation of Ruby is out of date or broken. Mac OSX comes with a default Ruby installed, but I honestly have no idea if it's complete or out of date because I always install my own.

Getting a Build Environment Ready

By default, MacOSX does not have the capacity to build C applications, which is what the "standard" ruby runtime is. So, you need to install a C building toolchain, which in many cases is GCC & friends.

Without XCode Installed

  1. Find the " Additional Developer Tools " link on the XCode product page
  2. Click it
  3. Find and install the " Command Line Tools " for your version of OSX

With XCode Installed

  1. Open XCode
  2. Open the Downloads preferences pane
  3. Find the " Command Line Tools " and install them

Once you've installed them, close any open terminal windows before proceeding to ensure that the build tools are in your path.

Installing Ruby

There are a few ways to get Ruby going on a new linux system, but the most widely recommended one is to use rvm .

RVM is a tool which helps install and manage different Ruby environments, so you can easily switch between them and upgrade (or downgrade for a specific project or issue). It's found here (direct link to the installation instructions) You most likely want to do the first of the Quick guided installs, which will simply install it for your user. It'll also install the latest stable version of ruby.

There is a GUI for installing RVM, called JewelleryBox . It's fairly pretty and will notify you when there's new versions.

Once the app itself is installed:

  1. Click Add Ruby in the toolbar
  2. Choose a Ruby version. MRI is the "Official" ruby... It's the one which kicked everything off. For now, the latest stable is ruby-1.9.3-p327, so pick that one ;)
  3. Make sure the make default checkbox is ticked, then hit the "Install" button.
  4. Hopefully everything worked!

Installing Rails

Ruby's almost ubiquitous means of fetching libraries, including Rails, is with rubygems and the gem command. In this case, gem install rails should get you started. Oh, and make sure you open a new terminal window after installing a new ruby, and check it's installed with ruby -v .

Another nice thing

Bundler is a neat package manager built on top of rubygems. Install it with gem install bundle (oh, and Rails will install it as a dependancy). Its got its docs at this link but for basic, raw rails, you shouldn't need to do anything with it.

Good Luck

Have a blast learning Rails, I hope you find it makes webapp development more fun for you ^_^

我尝试了很长时间才能使Rails在Mac OS X上平稳运行,而我能找到的最佳解决方案是通过JewelryBox安装。

Do you have the file

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

cause I don't and I'm on Mac OS X as well...

Firstly create a rvm version with ruby version.
And create a gemset with some name under that rvm.
Do gem install bundler before installing any thing.
Then install rails with gem install rails which installs the latest version of rails.
And go ahead.

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