Archive for the ‘rvm’ category

How to solve “Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension”

March 2nd, 2012

With the joys of ruby 1.8.7 on OS X 10.7.3, i had to include a manual build step to get get mysql to build. This was the error i was seeing:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lmygcc… no
checking for mysql_query() in -lmysqlclient… no
*** 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.

The solution was to manually install the gem that had been stored in the temporary directory:

cd~/.bundler/tmp/85326/gems/mysql-2.8.1/

sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config

Once done, bundle install worked and used the installed gem

Running Ruby 1.8.7 and 1.9.2, RVM 1.10.3, OS X 10.7.3 and Xcode 4.3

February 24th, 2012

I recently updated to OS X 10.7.3 and RVM 1.10.3. The OS X update seems to have confused rvm by changing to a different compiler, resulting in ‘rvm install’ falling with this error:

The provided compiler ‘/usr/bin/gcc’ is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.

The solution that worked for me to install 1.8.7 was to tell rvm which compiler to use:

CC=/usr/bin/gcc-4.2 rvm install 1.8.7

This worked as expected.

However, trying to install 1.9.2 or above using the same method failed. So, i tried reinstalling Xcode, to no-avail. I then uninstalled Xcode devtools (sudo /Developer/Library/uninstall-devtools) and installed osx-gcc-installer. After this, i was able to install 1.9.2 using ‘CC=/usr/bin/gcc rvm install 1.9.2′, but it reported errors

Ruby ‘ruby-1.9.2-p290′ was build using clang – but it’s not (fully) supported, expect errors

Let’s see how well this works out. If i get errors, there must be a different compiler i can force rvm to use.

Well, the lack of Xcode devtools resulted in this error when Installing rmagick (2.13.1) with native extensions:

checking for stdint.h… *** 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.

So, i re-installed devtools and tried again. Let’s see how well this works.

Update

1.9.2 is working fine, but 1.8.7 is raising this error:

~/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault

Time to investigate what’s going on here!

1. rvm uninstall 1.8.7 && CC=/usr/bin/gcc-4.2 rvm install 1.8.7

Same error: ~/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault

2. rvm uninstall 1.8.7 && CC=/usr/bin/gcc-4.2 rvm install ruby-1.8.7 –force

Same error: ~/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault

3. rvm install ree

Worked!

So, it seems that this setup requires ree

Using rvm in conjunction with bundler

November 16th, 2011

I’m starting to use rvm with my rails projects and am wondering how to be use it in conjunction with bundler, as bundler already does a good job of managing the gems i need in my project.

To keep things simple for now, i’ve decided to keep bundler doing what it’s been doing (managing the project gems), and use rvm to simply specify the versions of ruby and bundler to use within the project.

So, in my project folder, i have 2 files, 1 for rvm and 1 for bundler:

  • .rvmrc
    This includes only the following:
    rvm use 1.9.2@development –create
  • Gemfile
    Includes all gems need within the project

The @development specifies that the app is using this rvm gemset, meaning that if i wish, i could have multiple gemsets and switch between them. As i’m currently handing off most of the gem management responsibility to bundler, this doesn’t makes sense at the moment, but could be useful later as i possibly migrate further responsibility over to rvm over time.

Making rvm gemsets work under OS X Lion with XCode 4.2

November 16th, 2011

Running Xcode 4.2 on OS X will cause issues with RVM. Here are details of the issues and fix.The process takes no more than 5 minutes in total.

Issue

gem install bundler
/Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/timeout.rb:60: [BUG] Bus Error
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0]

Abort trap: 6

Fix

  1. Install Xcode 4.2
  2. Install the gcc standalone compiler from https://github.com/kennethreitz/osx-gcc-installer (which replaces Xcode)
  3. Add “export CC=gcc-4.2″ to your ~/.bash_profile or equivalent (don’t forget to reload it)
  4. Run “rvm implode” then re-install rvm http://beginrescueend.com/