1

I'm just tried to create a new rails app on a server running rails 3.2.5 (ruby 1.8.7), using a mysql backend:

rails new myapp -d mysql

So far everything went well. However if I try to create the database with rake db:create I get this:

Could not find gem 'therubyracer (~> 0.12.0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.

If I do as recommended (run bundle install) I get a list of gems which are going to be used (and seem to installed already) aand at the another error occurs:

...
Using ref (1.0.5) 
Using sass (3.2.13) 
Using sass-rails (3.2.6) 
Installing therubyracer (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby18 extconf.rb 
checking for main() in -lpthread... yes
checking for v8.h... no
*** extconf.rb failed ***

So to me this suggests that rake is looking for v8 in the wrong location. The error posting also makes a suggestion on how to solve this using configuration options:

You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby18
--with-pthreadlib
--without-pthreadlib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError) and *not* the one that is bundle with the libv8 rubygem. However, it could not be located. please make sure you have a version of v8 that is compatible with 3.16.14.3 installed. You may need to special --with-v8-dir options if it is in a non-standard location

It looks like I have to configure the bundle process like bundle config --some-option but which option would do the trick? I've tried all those v8 related options but none of them worked. The option beginning with --with-v8-xxx don't seem to allow setting a path to the locally installed v8 lib (gem list gives me Using libv8 (3.16.14.3) and I can see the folder in my local .gem directory). The --without-v8-xxx aren't usable either as I don't know the location of the system-wide v8 lib (don't have the permissions to search the server).

How can I solve my problem?

Thanks


Ok, looks like I've been able to proceed a bit. Invoking installation like RUBYOPT=-rrubygems gem install libv8 seems to have convinced extconf.rb to look for v8.h in my local gems rather than in a system location. However, I'm not there yet:

ERROR:  Error installing therubyracer:
ERROR: Failed to build gem native extension.

    /usr/bin/ruby18 extconf.rb
checking for main() in -lpthread... yes
*** extconf.rb failed ***

... and later:

/kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `initialize': No such file or directory - /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/.location.yml (Errno::ENOENT)
from /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `open'
from /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `load!'
from /kunden/378731_1150/.gem/ruby/1.8/gems/libv8-3.16.14.3/lib/libv8.rb:6:in `configure_makefile'
from extconf.rb:32

The error posting also offers me a couple of option I could use but I don't at all understand what causes the error.

Any ideas?

Thanks

2 Answers 2

3

You can use bundle config to pass the configuration flags to your gems, like this

bundle config build.libv8 --without-v8-lib=/path/to/lib

Check bundle config man page for more info by running bundle help config

UPDATE: Judging by the error message you got, it seems that the libv8 gem was being built while looking for the system's v8 (not sure why this was the default). Luckily, the gem is bundled with v8 source, but you need to explicitly tell it to use it, like this

bundle config build.libv8 --without-system-v8
5
  • Ah, thanks. Now I see I got a .bundle directory in my home dir, containing the configuration that I've set just before. However, things still don't work - I don't know the without path (unfortunately). Simply changing --without-v8-lib to --with-v8-lib and providing the path to my locally installed gem doesn't work (I think --with-v8-lib doesn't take any path...)
    – 5tefan
    Jan 15, 2014 at 17:48
  • I'm sorry to say - bundle config build.libv8 --without-system-v8 didn't do the trick either. Still bundle install is looking for v8.h in the wrong location: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/bin/ruby18 extconf.rb checking for main() in -lpthread... yes checking for v8.h... no *** extconf.rb failed ***
    – 5tefan
    Jan 15, 2014 at 20:48
  • You sure that's not because of a conflict between the flags you set before (--with-v8-lib) and the system-v8 flag? Jan 15, 2014 at 21:06
  • I guess so... as far as I can see all set the --without-system-v8 option did was rewrite ~/.bundle/config to BUNDLE_BUILD__LIBV8: --without-system-v8
    – 5tefan
    Jan 15, 2014 at 21:23
  • I'm afraid I have nothing more to help you with, sorry. Jan 15, 2014 at 21:25
0

You can use this:

gem install libv8 -v 3.11.8.17 -- --with-system-v8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.