Pregunta

I'm trying to install libv8 3.16.14.3 but getting an error on OSX Mavericks using latest stable rvm and ruby-1.9.3-p125.

This is the output of running the command 'gem install libv8':

~/src(branch:master) » gem install libv8
Fetching: libv8-3.16.14.3.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
  ERROR: Failed to build gem native extension.

    /Users/me/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make[1]: *** [/Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/libpreparser_lib.a] Error 1
make: *** [x64.release] Error 2
/Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
  from /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
  from /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
  from /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
  from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
  build/gyp/gyp --generator-output="out" build/all.gyp \
                -Ibuild/standalone.gypi --depth=. \
                -Dv8_target_arch=x64 \
                -S.x64  -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o
  CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o
  LIBTOOL-STATIC /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/libpreparser_lib.a


Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/gem_make.out
¿Fue útil?

Solución

This is due to the fact that OS X 10.9+ is using version 4.8 of GCC. This is not supported officially in older versions of libv8 as mentioned in the pull request (https://github.com/cowboyd/libv8/pull/95). Please try bumping up the version of libv8 in your Gemfile (or) a bundle update should suffice. Hope this helps.

From the libv8 README

Bring your own V8

Because libv8 is the interface for the V8 engine used by therubyracer, you may need to use libv8, even if you have V8 installed already. If you wish to use your own V8 installation, rather than have it built for you, use the --with-system-v8 option.

Using RubyGems:

gem install libv8 [-v YOUR_VERSION] -- --with-system-v8

Using Bundler (in your Gemfile):

bundle config build.libv8 --with-system-v8

Please note that if you intend to run your own V8, you must install both V8 and its headers (found in libv8-dev for Debian distros).

Bring your own compiler

You can specify a compiler of your choice by either setting the CXX environment variable before compilation, or by adding the --with-cxx= option to the bundle configuration:

bundle config build.libv8 --with-cxx=clang++

Edit:

If this issue is brought on by therubyracer, try the following as suggested by rider_on_rails here:

gem uninstall libv8

gem install therubyracer -v YOUR_RUBY_RACER_VERSION

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

Otros consejos

You can actually install that version on Mavericks:

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

I can confirm this works with rbenv and ruby 1.9.3p448

El Capitan Solution for me:

$ brew install v8
$ gem install libv8 -v REQUIRED_LIBV8_VERSION -- --with-system-v8

Where REQUIRED_LIBV8_VERSION for me was 3.16.14.7, but you need to check which is the one you need in your bundle (this was the one for rails 4.2.5)

You may also need to run the commands above as the superuser (if your gems and system libraries are global)

You can configure bundler instead of having to know each version. @3.15 could be replaced with other versions.

$ brew install v8@3.15
$ bundle config build.libv8 --with-system-v8
$ bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
$ bundle install

My issue is since therubyracer, when update to macOS 10.15 and ruby-2.6.5

And the following works for me:

brew install v8@3.15

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

gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8@3.15

When I tried the accepted answer, libv8 would install successfully with gem install libv8, but bundle install would fail on libv8. I think that bundle install was trying to install a different version of libv8. I was able to find a solution that worked for me.

I needed libv8 because therubyracer depends on it. To get it to install, I noted the version that was failing to install in the gem_make.out log for therubyracer. (The path for the gem_make.out log will be in the failure message.) In my case it was 3.16.14.7. (This version will probably change over time, in case you're reading this three years from now.) Then I did this:

gem install libv8 -v 3.16.14.7 -- --with-v8-lib <-- note different flag from accepted answer

which allowed this to work:

gem install therubyracer

which allowed me to complete my bundle install.

This worked for me on OSX Yosemite.

https://github.com/cowboyd/therubyracer/issues/339

jasonlynes's solution found on that link made the trick for me. anything else didn't work.

brew install homebrew/versions/v8-315
brew link --overwrite v8-315 --force
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -v '0.12.2' -- --with-system-v8

I updated to macOS Catalina @ 10.15 and ruby 2.6.5. After a while got libv8 and therubyracer to install again, although I'd recommend not to update macOS yet (I heard ruby should be fine).

First, I had to update XCode

  1. xcode-select --install

I used rbenv to update ruby, and set the ruby version manually in /Users/<username>/.rbenv/version to 2.6.5. Although this shouldn't matter if your project contains a .ruby-version file.

Then I cleaned up any version I installed fro libv8 (usually in /usr/local/opt/): brew uninstall v8, brew uninstall libv8@3.15

  1. brew install v8@3.15

Now, following https://github.com/cowboyd/libv8#do-i-get-a-binary, I installed

  1. gem install libv8 -v '3.16.14.19' -- --with-system-v8

and then could run bundle install without errors.

None of this helped me... no matter what I did, my gem install of therubyracer kept complaining with this error:

Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Beginning compilation. This will take some time.
Building v8 with env CXX=clang++ LINK=clang++  /usr/local/bin/gmake x64.release ARFLAGS.target=crs werror=no
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
              -Ibuild/standalone.gypi --depth=. \
              -Dv8_target_arch=x64 \
              -S.x64 -Dmac_deployment_target=10.15 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror=''
  File "build/gyp/gyp", line 12
    except ImportError, e:
                      ^
SyntaxError: invalid syntax
gmake: *** [Makefile:268: out/Makefile.x64] Error 1

What ultimately helped me was this other forum I stumbled upon at https://www.bountysource.com/issues/82833405-libv8-fails-to-build-on-catalina-10-15

The final solution that worked for me:

I had to add these lines to my .zshrc file:

export CXX=clang++
export GYPFLAGS=-Dmac_deployment_target=10.15

Then I had to run these commands:

source ~/.zshrc
brew tap homebrew/homebrew-core
brew install v8@3.15
gem uninstall therubyracer
gem uninstall libv8
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/v8@3.15
bundle install

I hope someone else finds this useful!

Try with what I summarized in this question: "gem install therubyracer -v '0.10.2'" on osx mavericks not installing

It worked for me (OS X Mavericks)

I had this same problem when I upgraded from OSX Mountain Lion to OSX Mavericks. The accepted answer worked for libv8, but not when I went to bundle install therubyracer gem.

Upgrading from ruby-1.8.7-p354 to ruby-1.8.7-375 did the trick for me. libv8 (3.16.14.3-x86_64-darwin-13) and the therubyracer (0.12.0) gems installed without problem.

assuming you use rbenv:

rbenv versions
  system
  * 1.8.7-p354
  2.0.0-rc2

rbenv uninstall 1.8.7-p354
rbenv install 1.8.7-p375

rbenv versions
  system
  * 1.8.7-p375
  2.0.0-rc2

bundle install

This worked fine for me:

Try installing this pre-compiled gem:

https://dl.dropboxusercontent.com/u/7919548/gems/libv8/libv8-3.11.8.17-x86_64-darwin-13.gem (sha1:5ce07aaf4085fff5a5e10fe018fd6b22021bef3b)

Or if you prefer to build your own:

  git clone https://github.com/cowboyd/libv8.git
  cd libv8
  git checkout 3.11
  bundle install
  bundle exec rake clean build binary
  gem install pkg/libv8-3.11.8.17-x86_64-darwin-13.gem

Source: https://github.com/cowboyd/libv8/issues/107

Thanks to Felix Bünemann for the fix!

I tried a number of solutions outlined in previous answers, but found that running bundle (to install other, missing gems) would attempt to re-compile libv8 (despite having already installed it successfully using --with-system-v8) and thus suffer from the same issue.

Eventually, I found that removing the libv8 gem, fetching the gem file from rubygems, and then manually installing the .gem file with the --with-system-v8 flag worked for me.

i.e.

gem uninstall libv8
gem fetch libv8 -v LIBV8_VERSION
gem install libv8-LIBV_VERSION.gem -- --with-system-v8
bundle

Thanks to Gaurav Agarwal's answer for leading me down the right path!

You can try manually compiling and installing the gem via the method mentioned on the libv8 github site.

In MAC-Yosemite with RVM environment and ruby-2.1.1 version

gem install libv8 -v 3.16.14.3 -- --with-v8-lib gem install therubyracer

It works with the help of above command, can confirm this.

What really worked for me was upgrading ruby to 2.2.0, removing Gemfile.lock and bundling over again.

Worked like a charm!

This is what worked for me.

replace 3.16.14.7 with your version.

bundle install
gem install libv8 -v '3.16.14.7' -- --with-system-v8

bundle install
gem uninstall libv8 -v '3.16.14.7' -- --with-system-v8

brew install homebrew/dupes/apple-gcc42

export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2

bundle install

I have faced a similar problem on El Cap. Here's what I did.

brew tap homebrew/dupes
brew install apple-gcc42

And then,

export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2

Finally,

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

I was using a beta version of Xcode for another project and had forgotten. Switch back with xcode-select. Something like:

sudo xcode-select --switch /Applications/Xcode.app/

Remove from Gemfile:

gem 'therubyracer', :platforms => :ruby

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top