rubyjs/therubyracer

error installing therubyracer error failed to build gem native extension

anandraj007 opened this issue ยท 4 comments

here is the error i am getting .

$ sudo gem install therubyracer -v '0.12.2' --source 'http://rubygems.org/'

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

    /Users/letsventure/.rbenv/versions/2.2.4/bin/ruby -r ./siteconf20191111-5081-xr5qij.rb extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... 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.

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=/Users/letsventure/.rbenv/versions/2.2.4/bin/$(RUBY_BASE_NAME)
	--with-pthreadlib
	--without-pthreadlib
	--with-objclib
	--without-objclib
	--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
/Users/letsventure/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with 
the libv8 rubygem. 

However, your system version of v8 could not be located. 

Please make sure your system version of v8 that is compatible 
with 3.16.14.19 installed. You may need to use the 
--with-v8-dir option if it is installed in a non-standard location
	from /Users/letsventure/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
	from extconf.rb:32:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/letsventure/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/therubyracer-0.12.2 for inspection.
Results logged to /Users/letsventure/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-19/2.2.0-static/therubyracer-0.12.2/gem_make.out

ps : i tried all method given in stackoverflow like uninstall libv8 then install therubyracer

Same issue on Mac OS Catalina Version 10.15.1 (19B88

Having the same problem, specifying all possible paths as options does not resolve this problem for me whatsoever:

gem install therubyracer -v 0.12.3 -- --with-v8-include=/usr/local/Cellar/v8/7.8.279.23/libexec/include --with-v8-lib=/usr/local/Cellar/v8/7.8.279.23/libexec

Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
        ERROR: Failed to build gem native extension.

        /Users/olivar/.rbenv/versions/1.9.3-p551/bin/ruby extconf.rb --with-v8-include=/usr/local/Cellar/v8/7.8.279.23/libexec/include --with-v8-lib=/usr/local/Cellar/v8/7.8.279.23/libexec
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... 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.

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=/Users/olivar/.rbenv/versions/1.9.3-p551/bin/ruby
        --with-pthreadlib
        --without-pthreadlib
        --with-objclib
        --without-objclib
        --enable-debug
        --disable-debug
        --with-v8-dir
        --without-v8-dir
        --with-v8-include=${v8-dir}/include
        --with-v8-lib=${v8-dir}/
/Users/olivar/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with 
the libv8 rubygem. 

However, your system version of v8 could not be located. 

Please make sure your system version of v8 that is compatible 
with 3.16.14.19 installed. You may need to use the 
--with-v8-dir option if it is installed in a non-standard location
        from /Users/olivar/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
        from extconf.rb:32:in `<main>'


Gem files will remain installed in /Users/olivar/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/olivar/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.3/ext/v8/gem_make.out

I got two methods to solve this issue

bundle install --no-deployment command
and then bundle install
if this method didn't work try this one

  • brew unlink v8
  • brew link --force v8-315
  • gem install therubyracer -v '0.12.2' -- --with-system-v8

Neither of those suggestions work on older Ruby versions