简体   繁体   中英

Macbook Pro Rails Installation Error

I recently bought a macbook pro and downloaded the Mac OS mountain lion. I was told that ruby was already pre installed and that to download rails, I would type:

$ sudo gem install rails

However, when I do this, I get this error:

Building native extensions.  This could take a while...
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

I have looked around stackoverflow for answers and tried downloading Xcode version 4.4.1, except $ sudo gem install rails still doesn't work. Also, when I try the command without sudo, it tells me:

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

Is there a solution to fixing this problem? Other people have mentioned something called rvm, except I don't really know what that is or how to use it.

Had a similar problem on same system as above. Xcode doesn't include the command line tools pre installed. To install these, go to preferences -> downloads section and select components, then download command line tools. This may or may not solved the above problem.

RVM allows you to switch between Ruby versions. You may not want to develop RoR apps with the default Ruby on Mountain Lion, and rather than replacing the system installed ruby, RVM allows you to use other (ie later) Ruby versions without impacting your base installed Ruby that comes with OS X.

I have previously used this as a guide when setting up Ruby On Rails under OS X:

http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac

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