Not sure what happened but when I upgraded to Mavericks it says that Rails it not install. I executed the following command:
rails --version
And it said "Rails is not currently installed and run sudo gem install rails".
I run sudo gem install rails and get the following:
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/json-1.8.1 for inspection.
UPDATE:
I ran the command gcc --version and got the following:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
You need to install the Command Line Developer Tools. Just open Terminal and type up a command that requires it -- for instance, git, gcc or make. Or use the following command:
$ xcode-select --install
You'll see an alert like this:
Just click Install and that's it. As of OS X 10.9, there's no longer need to install Xcode for Ruby development.
Credit for the steps and picture goes to Daniel Kehoe in his latest guide: http://railsapps.github.io/installrubyonrails-mac.html
I had the same problem which I have now been able to solve.
The problem for me was that I had updated to the latest version of Xcode through the appstore but hadn't actually opened the application to complete the install. So here's what solved it for me:
Updated Xcode
Opened Xcode application
Accepted license agreement
Installed rails
Hope it works for you too.
It wasn't working for me even when I reinstalled xcode and the command line tools for mavericks.
But after that, I just did a bundle update and, for some reason, it worked.
I think I had the same issues. I updated the xcode and open xcode to accept licence aggrement. Then it worked fine as far as I can remember.
Related
I am trying to install and get running Rails Starter kit. On running bundle install, I get the following :
Your Ruby version is 2.3.0, but your Gemfile specified 2.1.3
So I have changed this line to ruby '2.3.0' and try again the command : see here.
It seems like I am unaible to build the gem native extension, and I don't find any workaround.
Note 1 : I have tried with both 2.3 and 2.3.1.
Note 2 : I have RV.
Thanks!
I may be relating to the 'json' native extension compiling.
If you're on Mac ensure you've Xcode developer kit installed. On Linux, a workaround is to have libgmp3-dev library installed (sudo apt-get install libgmp3-dev) as indicated in this issue.
For Windows users, DevKit is needed.
I am trying to install rails on my mac, but every time I type sudo gem install rails into the command line, I get the following error message. I have been stuck for a while, hope you can help.
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.14 for inspection
Results logged to /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.14/ext/gem_make.out
If you are trying to install Rails 4.0, it needs RubyGems 2.0.3, so you have to update your system by using following command
gem update --system 2.0.3
and then continue with your installation.
Hope it helped
I would just use rvm. It should work like a charm. Or you could dig around and see if you can find that ruby.h file its talking about. But I personally think the latter would be a pain in the ass.
Upgrade xcode by typing following command in terminal window-
xcode-select --install
This should solve your isssu.
yea the rvm works like a charm and it will come in handy when you want to switch between different rails versions
I had the same issues. I upgraded my version (using RVM) of Ruby from 2.0.0-p195 to 2.0.0-p353 (make sure you tell RVM to use the new version as the default). After this I did gem install rails again and it worked fine.
Make sure you have installed the right version of DevKit, you can get it from here...
http://rubyinstaller.org/downloads/
and install as it says here:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit#installation-instructions
if you still have the problem even after Upgrading Xcode.
Its may be because :
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning.
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
Personally I have got this problem while installing json gem , I did :
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install json
And the problem was solved.
After updating to OS X 10.9 Mavericks I tried to start a Rails 3 app, but the connection to the PG database was not working. Checking on PGAdmin III, the database is still there and it works fine.
So I tried to reinstall the pg gem:
gem uninstall pg
gem install pg
But the last command doesn't succeed, and gives the following error:
Building native extensions. This could take a while... ERROR: Error
installing pg:
ERROR: Failed to build gem native extension.
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for pg_config... yes Using config values from
/usr/local/bin/pg_config
* extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check
the mkmf.log file for more details. You may need configuration
options.
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in
`try_do': The compiler failed to generate an executable file.
(RuntimeError) You have to install development tools first. from
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in
try_link0' from
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in
try_link' from extconf.rb:39:in `'
I guess the problem is related to the Xcode developer tools. I updated Xcode to the latest version, but that didn't solve the problem. Do you know how to fix it?
You're right that the problem is related to the Xcode developer tools. It's not a bad idea to make sure you have all the developer tools installed (as opposed to solely installing gcc as mentioned in the previous answer):
Open up Xcode
In the application menu item "Xcode" select Open Developer Tool > More Developer Tools...
This takes you to a site with a bunch of software. Go ahead and download and install "Command Line Tools (OS X Mavericks) for Xcode - Late October 2013".
You will now be able to properly install the gem.
For anyone else coming to this issue off of a fresh install of the Postgres 9.3.0 app on Mac OS X Mavericks (i.e. you're not using homebrew for your Postgres installation) you may notice that even though you can build the pg gem you cannot run rake because of a dylib issue:
rake aborted!
dlopen(/Users/[USERNAME]/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/pg-0.15.1/lib/pg_ext.bundle, 9): Library not loaded: #loader_path/../lib/libpq.5.dylib
Referenced from: /Users/[USERNAME]/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/pg-0.15.1/lib/pg_ext.bundle
Reason: image not found - /Users/[USERNAME]/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/pg-0.15.1/lib/pg_ext.bundle
Unfortunately this is a problem with the current release version of 9.3.0 of Postgres. Winding back to a previous version will fix it for you:
uninstall the pg gem: gem uninstall pg
delete your 9.3.0 Postgres app by dragging it to the trash and emptying the trash
install version 9.2.2.0 of the Postgres app here: http://postgres-app.s3.amazonaws.com/PostgresApp-9-2-2-0.zip
reinstall the pg gem: gem install pg
*Thanks to the comment by jhiro009 on this thread for pointing me in the right direction on this last Postgres app part of the issue although the 9.2.4.3 version that he mentioned didn't work for me.
Using homebrew fixed this for me:
gem uninstall pg
brew install apple-gcc42
gem install pg
EDIT: I also manually installed "devtools"
xcode-select --install
On OS X Mavericks
sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2
gem uninstall pg; gem install pg;
works with homebrew Postgresql (9.3.1) installation and Apple Command Line Tools installed (pg 0.17.0).
None of the previous solutions worked for me (I just upgraded to Mavericks and updated XCode). Instead, I installed Postgress.app. and called
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
None of the solutions worked for me, and I didn't want to use MacPorts. Try and download the Postgres App and put it into the Application directory.
Then, specify the location of newly downloaded pg_config, which resides inside the app:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
If you run in to missing headers problem, try specifying the include directory of the app:
gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/MacOS/include/'
If you are looking for just a quick fix, add the following to your database.yml file:
host: localhost
I had the exact problem, added that line, and now all is well.
I had luck following this post from the guys at New-Bamboo:
3 Quick Tips for Coding with OS X 10.9 Mavericks
After installing the xcode dev tools, the third step sorted everything out:
brew tap homebrew/versions && brew install apple-gcc42
brew link --force apple-gcc42
ln -nsf $(which gcc-4.2) /usr/bin/gcc-4.2
I had this problem the first time I tried to install pg. Through various trials and errors I found something that worked. Thankfully, my notes also worked when Mavericks broke everything.
Hope this helps:
Do not do any brewing.
download the enterpriseDB one-click installer, mount and run.
If it doesn't work, run it through the command line (unattended mode) and it will change the memory settings. Restart, run again.
Makes a user called postgres with the password you supply. Also installs pgadmin III.
run this in app directory:
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-include=/Library/PostgreSQL/9.2/include/ --with-pg-lib=/Library/PostgreSQL/9.2 sudo env ARCHFLAGS='-arch i386' gem install pg/lib/
Open pgadmin3 and create a user and password for rails, then add it to config.
psql [database_name] # to check on your db. Or use pgadmin III
I'm stuck trying to install rails on my mac. I have OS X 10.6.8 and I have confirmed that I have Ruby, version 1.8.7
I ran sudo gem update and sudo gem update --system to get the latest versions of the software.
However, when I run sudo gem install rails I get this error:
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.6.3 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.6.3/ext/json/ext/parser/gem_make.out
If you have XCode 4 or later you will need to open it and go to Preferences -> Downloads -> Components and install the Command Line tools as they aren't installed by default. Couldn't install Rails until this happened.
Im using osx 10.10. You can download from the command-line
xcode-select --install
Not sure what it needs to compile, but OSX can't compile any native ruby extensions at all unless the Apple developer tools are installed. On 10.7 Lion you can download it free from the app store, or Download it here for 10.6: http://developer.apple.com/xcode/index.php
It may also be on your OSX install discs, though probably much more out of date.
Did you install the OS X developer tools? You'll need to do this to be able to build native extensions
Just a follow up ...
it may be that you are on a mac and rails cannot find the right compiler for c headers.
just install xcode from apps store / homebrew or go to terminal ...
$ xcode-select --install
complete the installation and agree on the licensing etc, then ...
$ sudo gem install rails
There are two possible reasons for the fail:
PRIMARY REASON: Missing Xcode Command Line Tools
Verifying Xcode Command Line Tools Installation manually:
Check for presence of
"/usr/include/iconv.h" (if absent=>Missing or improperly installed Xcode CLT)
Installing Xcode CLT:
Try running xcode-select --install on terminal and follow the instructions. If it fails, open Xcode.app, select from menu "Xcode" - "Open Developer Tool" - "More Developer Tools" to open the developer site, download the installer for your OS version and run it.
SECONDARY REASON(if 1. fails): Version issues
Try upgrading the ruby version using rbenv.
Hope it helps!
Steps to sort out this issue:
Follow these steps unless error is fixed.
Open terminal and run commands:
sudo xcode-select --install
sudo xcodebuild -license accept
Make sure you have installed only one Xcode and it is the latest one. If more than one version is installed then keep only the latest one with name in applications like Xcode.app
Open Xcode->preferences->locations then check if any command line tools are selected; if not then select
Install Ruby by:
brew install ruby
Install CocoaPods by
sudo gem install cocoapods
Try to install Ruby via RVM. I solved in this way
How to install ruby on Ubuntu with rvm
The Command line tools didn't solve this issue for me.
I upgraded ruby installation through rbenv to 2.2.0, made that the global default ruby installation, and this issue was fixed.
Switch Ruby to Homebrew version:
$ brew install ruby
$ brew link --overwrite ruby
$ echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
$ echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.bash_profile
$ echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.bash_profile
Just had a similar issue. I can confirm that installing the command line tools fixes it.
https://stackoverflow.com/a/58226876/8070378
Solved after run:
sudo xcode-select --install
sudo xcodebuild -license accept
I had this problem on macOS Catalina 10.15.7, and it seems that Xcode 12.3's Ruby is a variant of 2.6, but my software needed 2.7.
I installed rvm and ran rvm install ruby-2.7, and now it works just fine 🎉
I used to have no problems at all with ruby, gems and all related stuff. But after installing X Code Developer Tools and upgrading to Lion the gems do not install.
I get the following error for every gem. This is the message for sqlite as an example:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
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/sqlite3-1.3.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.4/ext/sqlite3/gem_make.out
What went wrong? How to fix it?
I had to install the Command Line Tools in the latest Xcode-Version (4.3.1) and
sudo gem install rails
worked like a charm.
To install Command Line Tools, go to Xcode Preferences > Downloads or use the following command in terminal (thx #Purell):
xcode-select --install
I'm using Mavericks and Ruby 2.0.0 and I also got this error (mkmf.rb can't find header files) when installing gems. I solved this issue by creating some symbolic links in Terminal.
#First install developer tools again:
xcode-select --install
#Create symbolic link to Ruby include (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include
#Create symbolic link to config.h (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/Headers/ruby/config.h /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h
I faced same problem while trying to install rails on my Lion. This is how i could solve it.
Install rvm
$ curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
Install osx-gcc-installer
https://github.com/kennethreitz/osx-gcc-installer
Installed new version of ruby
rvm install 1.9.3
Typed to following command to show the requirements
rvm requirements
To use an RVM installed Ruby as default, instead of the system ruby:
rvm system ; rvm gemset export system.gems ; rvm 1.9.3 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.9.3
Installed rails:
sudo gem install rails
My Mac is now read for rails!! YAY!!
Not a direct solution to your problem, but I'd suggest using rvm to install fresh rubies and gems. That should take care of it.
While installing Rails I had the error :
can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
As i had already Xcode installed, I had just to install Command Line Tools to resolve this problem
You need to have XCode installed, it includes ruby.h as well as some other important files needed to compile other native gems.
Hello i'm sorry i can't test this answer but i would suggest to change the default search paths in your bashrc and extconf.rb since the Library files seem to be moved in Lion.
(P.S. if he wants to work with the default 1.8 Version, rvm would be an unneeded hassle)
Update to the latest version of xcode, that fixed the problem for me. Make sure xcodebuild is in your path.
running xcodebuild -version in a terminal window should output 4.2.1 (4.x at least).
After a OS-Update make sure that you do accept the X-Code license even when you have used command-line-tools before. Only then some header-files will be available. To accept the license you have to run X-Code once.
I just forgot to run it with the sudo command.
sudo gem install sqlite3
not:
gem install sqlite3