`gem install therubyracer` fails on Mac OS X Lion

后端 未结 11 539
再見小時候
再見小時候 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:14

    If you need 0.11.3 and it's failing give this a shot for Mac OS X 10.9...

    gem uninstall libv8
    brew install v8
    gem install libv8 -- --with-system-v8
    gem install therubyracer -v '0.11.3' -- --with-system-v8
    

    See this issue for more details.

    You probably don't need the -- --with-system-v8 on the last line but I did it just to be safe since I saw it start doing Fetching: libv8-3.11.8.17-x86_64-darwin-13.gem (1%) when I ran the command...

    Anyhow, it worked for me when all the other things did not.

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

    But, why is this happening, you ask? And why does uninstalling libv8 and reinstalling therubyracer fix the problem?

    The answer is at the bottom of the error message (from orig post). Ignore the stuff about

    probably lack of necessary libraries and/or headers
    

    This is an incorrect assumption by whoever wrote that error message. At the bottom, you see what Ruby has to say about it:

    undefined method `include_path' for Libv8:Module
    

    In my case, I was trying to install therubyracer-0.9.8 with bundle install, and for some reason, it was trying to use my copy of libv8-3.11.8.13, which had been installed at some point, probably as a dependency of some other gem.

    I don't know why it was trying to use the newer version, because therubyracer.gemspec contains s.add_dependency "libv8", "~> 3.3.10". And my Gemfile.lock says to use libv8 (3.3.10.2). But alas, that is indeed what was happening.

    And it's true that Libv8:Module does not have the method include_path in libv8-3.11.8.13, but it does in libv8-3.3.10.2

    So that is why uninstalling all of your versions of libv8 and then re-installing therubyracer works. Because all the versions of libv8 that do not have the method include_path are removed completely, and the libv8 that does have the method include path is reinstalled when you reinstall of therubyracer.

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

    At last I use therubyracer 0.11.0beta5 as a solution.

    Using therubyracer (0.11.0beta5)

    add following on Gemfile

    gem 'therubyracer', '~> 0.11.0beta5'
    group :libv8 do
      gem 'libv8', "~> 3.11.8"
    end
    

    then bundle install

    Mac OSX 10.8 Moutain Lion

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

    This worked for me:

    $ gem uninstall libv8
    $ gem install therubyracer
    

    (A big thanks to http://www.ruby-forum.com/topic/4306127)

    0 讨论(0)
  • 2020-12-04 08:24
    gem uninstall libv8
    brew install v8
    gem install therubyracer
    
    0 讨论(0)
提交回复
热议问题