Error installing gems that use native extensions on Ubuntu, Ruby 1.9.2 via RVM
This caused me a ton of aggravation at the Boston Hack Day when trying to install Vagrant (for which FFI is a dependency). I ended up wasting so much time that I switched machines to work around the problem.
After the fact, I found a hack that works (although I'm sure there's a better solution). The file that the error message is complaining about
~/.rvm/gems/ruby-1.9.2-p180/bin/rake
differs from other similar copies in that it's missing path setup stuff at the head, so I copied these lines from one of the files that had them:
[genericized per @danv's answer below. Thanks for the improvement!]
ENV['GEM_HOME']=ENV['GEM_HOME'] || '~/.rvm/gems/ruby-1.9.2-p180'
ENV['GEM_PATH']=ENV['GEM_PATH'] || '~/.rvm/gems/ruby-1.9.2-p180:~/.rvm/gems/ruby-1.9.2-p180@global'
ENV['PATH']='~/.rvm/gems/ruby-1.9.2-p180/bin:~/.rvm/gems/ruby-1.9.2-p180@global/bin:~/.rvm/rubies/ruby-1.9.2-p180/bin:' + ENV['PATH']
That fixed it for me. This was a new Ubuntu 10.10 install with no default Ruby installation (which could be part of the problem) and Ruby 1.9.2 installed using RVM. Lots of other gems installed fine, including those requiring native compilation, so the problem is something specific to FFI.
Error while installing Ruby on Rails
Install the gem as a normal user, not sudo:
gem install rails
Or install the ruby dev package. There are a lot of similar answers in SO:
Failed to build gem native extension — Rails install
Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)
Failed to build gem native extension (mkmf (LoadError)) - Ubuntu 12.04
Can't Install Curb - Having problems with native extensions.
On a Debian Squeeze, I've managed to install curb
with libcurl4-openssl-dev
installed before.
It may also work with libcurl4-gnutls-dev
, but I've no tested.
Problem installing linkparser on Ubuntu 10
Here is few steps I tried.
Get ruby source (1.9.2 p180 for now)
$ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
$ tar zxvf ruby-1.9.2-p180.tar.gz
export include path of ruby, you may write it in ~/.bashrc, to enable for other native extensions too.
$ export CPATH="`pwd`/ruby-1.9.2-p180/include":$CPATH
and looks like apt-get version of link-grammer is version 4.0 and linkparser complaining too old (>=4.7.0), so get and trunk version as they mentioned the site. v4.7.4 for now
http://www.abisource.com/projects/link-grammar/#download
note: if your ruby is in /usr/local/bin
, change --prefix=/usr
to --prefix=/usr/local
$ svn co http://svn.abisource.com/link-grammar/trunk link-grammar
$ cd link-grammar
$ ./autogen.sh
$ ./configure --prefix=/usr
$ make
$ sudo make install
$
$ sudo gem install linkparser
Building native extensions. This could take a while...
Successfully installed linkparser-1.1.0
1 gem installed
Installing ri documentation for linkparser-1.1.0...
Test codes to confirm working properly
ref: http://deveiate.org/code/linkparser/
$ irb
> require 'linkparser'
=> true
> dict = LinkParser::Dictionary.new( :screen_width => 100 )
> sent = dict.parse( "People use Ruby for all kinds of nifty things." )
> puts sent.constituent_tree_string
(S (NP People)
(VP use
(NP Ruby)
(PP for
(NP (NP all kinds)
(PP of
(NP nifty things)))))
.)
=> nil
> puts sent.diagram
+---------------------------------Xp--------------------------------+
| +-----MVp----+-----Jp-----+ +------Jp-----+ |
+----Wd---+--Sp--+--Os--+ | +--Dmc-+--Mp-+ +----A---+ |
| | | | | | | | | | |
LEFT-WALL people.p use.v Ruby.f for.p all.a kinds.n of nifty.a things.n .
=> nil
Failed to build gem native extension
The problem is that in Lion Xcode 4.3 doesn't by default install (or even include) the command-line tools such as gcc - and those are what are needed here. In the Downloads pane of Xcode's prefs, under Components, ask for the command-line tools. (See the readme: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Chapters/
xcode_4_0.html#//apple_ref/doc/uid/TP40016147-SW35)
Actually I believe you didn't need to install Xcode at all, since in fact the command-line tool can now be downloaded and installed separately.
Related Topics
Rails: Modifying a Model Generated by Scaffolding
Is 'Yield Self' the Same as Instance_Eval
Rubygems + Cygwin: Posix Path Not Found by Ruby.Exe
How to Take Screenshots of Web Pages Using Ruby and a Unix Server
Rails 4 Before_Action, Pass Parameters to Invoked Method
How to Access Url Helper from Rails Module
How to Describe an Enumeration Column in a Rails 3 Migration
Ruby Check If Nil Before Calling Method
Implementation of "Remember Me" in a Rails Application
Adding Attributes to a Ruby Object Dynamically
Ruby: Create a String from Bytes
Why Is Safe Navigation Better Than Using Try in Rails
Check If User Is Active Before Allowing User to Sign in with Devise (Rails)
Make Rake Task from Gem Available Everywhere
Vim Command-T Plugin Error: Could Not Load the C Extension
Is Rails.Cache Purged Between Tests