Installing libv8 gem on OS X 10.9+

后端 未结 20 918
旧时难觅i
旧时难觅i 2020-11-29 14:41

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 \

相关标签:
20条回答
  • 2020-11-29 15:19

    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

    0 讨论(0)
  • 2020-11-29 15:19

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

    0 讨论(0)
  • 2020-11-29 15:20

    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!

    0 讨论(0)
  • 2020-11-29 15:20

    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
    
    0 讨论(0)
  • 2020-11-29 15:20

    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
    
    0 讨论(0)
  • 2020-11-29 15:20

    Remove from Gemfile:

    gem 'therubyracer', :platforms => :ruby

    0 讨论(0)
提交回复
热议问题