`gem install therubyracer` fails on Mac OS X Lion

后端 未结 11 538
再見小時候
再見小時候 2020-12-04 07:33

I would appreciate some help in getting gem install therubyracer to work. Here is the error:

$ gem install therubyracer
Building native extensio         


        
相关标签:
11条回答
  • 2020-12-04 08:00

    Considering none if the above worked for me 100%, I thought I'd post what did (as part of a rails project):

    gem uninstall libv8
    bundle update therubyracer
    

    This made sure I got the latest therubyracer, and also a more recent version of libV8, and seem to fix the multiple issues I was hitting, from missing libv8.a files, to undefined methods.

    0 讨论(0)
  • 2020-12-04 08:00

    For me, removing the Gemfile.lock file and running bundle install worked it's magic.

    0 讨论(0)
  • 2020-12-04 08:01

    For anyone encountering this issue on Mac OSX 10.8 Mountain Lion when attempting to upgrade their Gemfile with gem 'therubyracer', '0.11.0', just upgrading the system libv8 gem worked for me (no uninstallation of any other gem necessary):

    $ gem update libv8
    $ bundle install
    

    Edit

    If you use Travis-CI (or other CI tools located on other servers, I assume), you will need to explicitly add the libv8 gem to your Gemfile as well:

    Gemfile

    gem 'libv8', '3.11.8.3'
    

    then bundle install as usual. Just note that libv8 can take a significant amount of time to install and I've noticed that it may end up being the cause of going over Travis CI's timeout limits, causing your build to fail. You can mitigate this slightly be not including development environment gems in your builds:

    .travis.yml

    # ...
    bundler_args: --binstubs=./bundler_stubs --without development
    

    Update

    Yep, pretty much all my Travis builds timeout and fail because of this. If anyone knows a way to solve this problem (I would hope "downgrade therubyracer" is a last resort), please leave a comment!

    Update 2

    This may not work for all apps, but it seems that my Rails 3.2.9 apps didn't actually need therubyracer or libv8 after all. After removing those gems from my Gemfile, I confirmed that my specs passed, pushed again to Travis and it built successfully. So, I guess getting rid of those gems (if you're not sure you actually need them) is at least worth a try.

    Update 3

    Thanks to Paul Annesley for confirming that if you're on Mac OS X 10.8 Mountain Lion, you don't need therubyracer gem at all since the OS already comes bundled with Apple JavaScriptCore, its own Javascript runner. At the time of the original answer, I was on Snow Leopard and hence needed it.

    0 讨论(0)
  • 2020-12-04 08:05

    I got a similar issue, but it was also complaining about not finding g++-4.2. I did have XCode command line tools installed, but it was looking for /usr/bin/g++-4.2, I had g++ (which was a symbolic link pointing to llvm-g++-4.2). Anyway, I just created a symbolic link to g++ and tried the bundle install again... it worked!

    $ cd /usr/bin

    $ sudo ln -s g++ g++-4.2

    0 讨论(0)
  • 2020-12-04 08:06

    Had the same error, this worked for me:

    1. From console: gem uninstall libv8

    2. In your Gemfile, add the following:

      gem 'therubyracer', :platforms => :ruby, :require => 'v8'
      gem 'libv8', '~> 3.11.8'  # Update version number as needed
      
    3. From console: bundle install

    If you were in the middle of upgrading therubyracer gem, you may want to run bundle update therubyracer after that as well. (Consider specifying a version number)

    This was on Mac 10.6 (Snow Leopard).

    0 讨论(0)
  • 2020-12-04 08:07

    OSX 10.8.2, ruby 1.9.3p125

    None of the above worked for me... I got tired of trying to find the right gem for my environment, so I just soft linked to the g++ target this things was missing:

    sudo ln -s `which g++` /usr/bin/g++-4.2
    

    Not as helpfully for remote deployments, but get the job done on my workstation.

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