Installing RAILS on MAC OS 10.9 Mavericks (beta) - ruby-on-rails

I'm running OS X Mavericks 10.9 beta and now is a good time to get back to learning Ruby on Rails. Happy to know that 10.9 includes Ruby 2.0
But I'm having trouble installing Rails.
using the command - sudo gem install rails
results in this..
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/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.10 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.10/ext/gem_make.out
Any advice?
Thanks
Shannon

For me this problem was fixed by running the following command:
xcode-select --install

Try this post
It's not recommended to use your system Ruby, you can use it in a sandbox like RVM or rbenv.

Xcode 5 is required.
and ..
$ xcode-select -p
/Applications/Xcode5-DP3.app/Contents/Developer
it's work .
or
see Install Ruby 2.0 on Mac OS X without RVM

Make sure you're using Xcode 5.0.1 GM seed, not the Xcode downloaded from the App Store. That fixed a similar problem for me.

Related

Rails installation error - Failed to build gem native extension

I seem to have a conflict when trying to install Rails on Mountain Lion. I have tried updating Ruby but this did not help. I also tried Rails Installer but that also gave an error. Ruby version is 1.8.7
Here is the error I am getting from terminal
sudo gem install rails
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/atomic-1.1.10 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/atomic-1.1.10/ext/gem_make.out
I was having the same issues and I had all the requirements. My solution? Upgraded (through RVM) my version of Ruby from 2.0.0-p195 to 2.0.0-p353. After this I tried gem install rails and it worked like it was supposed to.
I installed the x-code command line tools and then the rails install worked correctly.
Use RailsInstaller and these step-by-step instructions:
I found the answer here, http://net.tutsplus.com/tutorials/ruby/how-to-install-ruby-on-a-mac/
Although by no means was this a walk in the park, due to version conflicts, the tut is over a year old and Rails now requires at least Ruby 1.9.3 and you need to install Command Line tools in Xcode. This tut uses RVM.
I tried Rails Installer which sounds a lot easier than doing it this way but that also gave me an error. I think I had major version conflicts going on. If you are trying to install Rails then I'd try Rails Installer first. Here's a very recent tut on installing it, http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac

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

Why won't bundler install the json 1.7.4 gem on OS X 10.8?

I'm on OS X 10.8 with XCode 4.4, Ruby 1.9.3, and Rails 3.2.
When I clone my rails project from git and run:
bundle install
I get:
Installing json (1.7.4)
Errno::EPERM: Operation not permitted - /Users/myuser/.rvm/gems/ruby-1.9.3-p0/gems/json-1.7.4/.gitignore
An error occurred while installing json (1.7.4), and Bundler cannot continue.
Make sure that gem install json -v '1.7.4' succeeds before bundling.
Then I try:
gem install json -v '1.7.4'
and get:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /Users/scalessec/.rvm/gems/ruby-1.9.3-p0/gems/json-1.7.4/.gitignore
Okay. Permissions issue, right? Let's try:
sudo gem install json -v '1.7.4'
No go. Here's what I get:
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/Users/myuser/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /usr/bin/gcc-4.2: Permission denied
make: * [generator.o] Error 1
What the heck?
I am not sure, but I upgraded to OS X 10.8 2 days ago (from Lion, where my Rails configuration worked fine). And I had the same JSON 1.7.4 issue.
Eventually, I solved the problem by noticing that Xcode's command line tools were NOT installed (but they were on OS X 10.7!). I just reinstalled CLI tools in Xcode and that JSON 1.7.4 issue disappeared.
Also just in case it's helpful, check out this guide: https://thoughtbot.com/blog/the-hitchhikers-guide-to-riding-a-mountain-lion
Thanks to aabulkhairov for his solution.
Here's one for anyone having the same symptom but still running OS X Lion
I was able to updating Xcode to 4.4 from the App Store, then using XCode > Preferences > Downloads to install CLI tools; this resolved the problem. The new XCode is compatible with Lion, and my Rails app is running as expected.
I think I got into this state because the previous version of XCode 4.2.1, installed from the App Store, had displaced my even older version downloaded from developer.apple.com -- that's likely where I lost the CLI tools. Since that time, I apparently never needed to compile a gem with native extensions again.
Re-install CLI tools worked for me.
Use the top answer here:
How to use/install gcc on Mac OS X 10.8 / Xcode 4.4
For OS X use:
sudo gem install json --pre for the latest one
Check the version of Ruby you are using. This can be installed easily with ruby 1.9.3. Change the ruby version to 1.9.3 and do
sudo gem install json -v '1.7.4'

Error installing Rails

I know other people have asked this but the suggested fixes don't seem to work for me. I'm trying to install Rails v. 3.2.3 on a Mac OS X Lion, using Ruby 1.8.7. In terminal:
$ sudo gem install rails -v 3.2.3
And then I get the error message:
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.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.0/ext/json/ext/parser/gem_make.out
I've seen some people suggest installing Xcode v. 4.3.2, which I have, but I'm not sure if I need to do something special with Xcode to get the Rails installation to work. Any help is appreciated.
The easiest install way is by using RVM
here is a pretty good guide:
http://thinkvitamin.com/code/ruby-on-rails/installing-ruby-rails-and-mysql-on-os-x-lion/

"gem install autotest-fsevent" -v 0.1.1 fails on snow leopard

Following Michael Hartl's Rails 2.3 tutorial. Excellent, so far, but I am stuck on the prep for the testing environment on page 87. Can't get the autotest-fsevent to install.
iMac i7 running Snow Leopard.
Typing the command in the Title, above, I get the following error message:
bash-3.2$ sudo gem install autotest-fsevent -v 0.1.1
Building native extensions. This could take a while...
ERROR: Error installing autotest-fsevent:
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/sys-uname-0.8.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/sys-uname-0.8.6/ext/gem_make.out
I've tried downloading a ruby 1.8.7 fresh install to get the header files, but that has not seemed to work. Copied them to the path in bold, above.
Any help will be greatly appreciated.
-lloyd
"Do you have Xcode installed?"
Thanks for checking. In fact, I didn't realize that there was a difference between Xcode in the standard Snow Leopard install and the one downloaded from the Apple Developer Network. I have installed the full Xcode and the problem is now solved.
Cheers,
lloyd

Resources