0

I can install other native extensions fine with rbenv's gem install. However, all servers (minus webrick) give me this problem:

Building native extensions. This could take a while...

ERROR: Error installing thin:

       ERROR: Failed to build gem native extension.

/custom_dir/.rbenv/versions/ruby-2.0.0-p247/bin/ruby extconf.rb

The output of gem_make.out is the same as the previous line. bundle install and bundle install --deployment work fine. The servers perform fine with bundle exec. However, I can't figure out why gem install puma|thin|etc fail. It's not important, but I'm wondering what is happening in case it's a symptom of another issue.

Another symptom: If I install thin or unicorn, I get the same error based on their dependencies. In other words, it tells me to look at kgio/gem_make.out or raindrops/gem_make.out, etc. However, if I install their dependenccies separatly: kgio, raindrops, etc., they install fine (using gem install kgio). But, when I try to install the final package, thin, unicorn, etc., it gives me the same error regarding ruby extconf.rb with no further details.

Another symptom: I can only compile Ruby 2.0 if I leave out rdoc/ri documentation. I get a make: *** [rdoc] Error 137 if I compile Ruby with documentation. I believe this is related to why the server gems won't compile. I have managed to install unicorn manually w/o Rubygems,, using Ruby 2.0.

Ruby 1.9. compiles fine, along with rdoc/ri documentation. puma and others install fine, even with rdoc/ri doc generation. So it seems it is a problem with:

  1. Ruby 2.0
  2. rdoc/ri generation

Update: Installing Ruby 2.0 with RVM (instead of rbenv) worked. Installing all other server gems works fine and the executables (eg puma) work fine. RVM seems to be doing something extra that rbenv/ruby-build is not.

dgo.a
  • 2,634
  • 23
  • 35
  • have you tried this http://stackoverflow.com/questions/15208525/error-installing-gem-failed-to-build-gem-native-extensions-cannot-load-such-f – Keval Doshi Aug 14 '13 at 17:53
  • run this: `where bundle` and see if this matches your Ruby 2.0 installation's bin path. – Kashyap Aug 14 '13 at 17:54
  • Do you mean `which bundle`? `where` is not installed on the system. – dgo.a Aug 14 '13 at 18:01
  • @Keval: I'm not using `sudo` for any of these calls. Is that what you thought the problem was? Thanks anyway. – dgo.a Aug 14 '13 at 18:05
  • did you try out the last answer in that link involving apt-get install – Keval Doshi Aug 14 '13 at 18:08
  • Yes. The package is called `ruby-dev` in ubuntu, `ruby-devel` in other distros like Fedora. I still get the same error: `.../bin/ruby extconf.rb` It's not complaining about missing libs. Esp. since the gems install fine with `bundle install` so I have all the necessary libs. I also checked the answer above it... `build-essential ... zlib1g...` Everything is up to date and installed. – dgo.a Aug 14 '13 at 18:20
  • Maybe I misunderstood here, but have you tried to do `bundle update`? That will fix dependencies as well as installing the gems. – Automatico Aug 14 '13 at 18:44
  • Yes, you misunderstood. I said, `bundle install` works fine. That also includes `bundle update`. It's when I install with `gem install [name]` that it fails. Thanks anyway. – dgo.a Aug 15 '13 at 04:08

5 Answers5

1

In my instance, it turned out to be a lack of memory on the virtual machine I was compiling on. I only had 256MB provisioned. Once I bumped it up to at least 512MB RAM this issue went away.

I was using rbenv and ruby-build in tandem.

Something in the RDoc compilation process must take up a lot of memory.

patcoll
  • 966
  • 6
  • 8
0

I have no idea why this "solution" works:

Compile ruby-2.0.0-p247 with the following flags:

./configure prefix=/change_this/to/your/needs --disable-install-doc --enable-shared

Those flags are the same ones used by RVM. puma, thin, and unicorn all install fine.

Note: rbenv users: change prefix= to your .rbenv/versions directory.

dgo.a
  • 2,634
  • 23
  • 35
0

@patcoll and @dgo.a are both correct: The failure is due to a lack of available memory. Disabling RDoc installation will resolve this.

However, you do not need to manually ./configure or enable shared rbenv.

Instead, install Ruby using rbenv's configure env var:

export CONFIGURE_OPTS="--disable-install-doc"; rbenv install 2.1.2
0

Using rbenv and with 512MB of memory it still failed, so:

CONFIGURE_OPTS="--disable-install-doc" rbenv install 2.1.2

It turns out that memory is not the issue, its disk space. Review your logs folders (du -sh).

givanse
  • 14,503
  • 8
  • 51
  • 75
0

When building Ruby 2 from source, configure with docs disabled if getting the make: *** [rdoc] Error 137 error.

./configure --disable-install-doc

This issue seems to occur in low memory environments (less than 512MB).

scarver2
  • 7,887
  • 2
  • 53
  • 61