简体   繁体   English

如何在新的Mountain Lion安装上安装libv8 ruby​​ gem?

[英]How do I install the libv8 ruby gem on a fresh Mountain Lion install?

I've been racking my head on this one. 我一直在讨厌这个问题。 I've followed suggestions in several related posts but to no avail. 我在几个相关的帖子中都遵循了建议,但无济于事。

I am starting from a fresh install of Mountain Lion, installed the Command Line Tools, and have Ruby 1.8.7 successfully installed based on a few other posts I've found for installing gcc-4.2 via Homebrew and adding a symlink to /usr/bin/gcc-4.2. 我从一个全新的Mountain Lion安装开始,安装了命令行工具,并根据我发现通过Homebrew安装gcc-4.2并在/ usr /中添加符号链接的其他一些帖子成功安装了Ruby 1.8.7斌/ GCC-4.2。

Now, however, I'm unable to successfully install libv8. 但是,现在我无法成功安装libv8。 The error below is as far as I've gotten off of the existing suggestions. 以下错误是我已经从现有建议中得到的。

Any additional input? 任何额外的输入?

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/Eric/.rbenv/versions/1.8.7-p352/bin/ruby extconf.rb 
creating Makefile
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Traceback (most recent call last):
  File "build/gyp/gyp", line 18, in <module>
    sys.exit(gyp.main(sys.argv[1:]))
  File "build/gyp/pylib/gyp/__init__.py", line 480, in main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "build/gyp/pylib/gyp/generator/make.py", line 2085, in GenerateOutput
    part_of_all=qualified_target in needed_targets)
  File "build/gyp/pylib/gyp/generator/make.py", line 756, in Write
    self.xcode_settings, self.Absolutify, self.Pchify))
  File "build/gyp/pylib/gyp/generator/make.py", line 1132, in WriteSources
    cflags = self.xcode_settings.GetCflags(configname)
  File "build/gyp/pylib/gyp/xcode_emulation.py", line 258, in GetCflags
    sdk_root = self._SdkPath()
  File "build/gyp/pylib/gyp/xcode_emulation.py", line 247, in _SdkPath
    return os.path.join(self._GetSdkBaseDir(), '%s.sdk' % sdk_root)
  File "build/gyp/pylib/gyp/xcode_emulation.py", line 233, in _GetSdkBaseDir
    raise Exception('Error %d running xcode-select' % job.returncode)
Exception: Error 2 running xcode-select
make: *** [out/Makefile.x64] Error 1
Using compiler: g++
GYP_GENERATORS=make \
    build/gyp/gyp --generator-output="out" build/all.gyp \
                  -Ibuild/standalone.gypi --depth=. \
                  -Dv8_target_arch=x64 \
                  -S.x64 -Dhost_arch=x64
xcode-select: Error: No Xcode is selected. Use xcode-select -switch <path-to-xcode>, or see the xcode-select manpage (man xcode-select) for further information.



Gem files will remain installed in /Users/Eric/Development/par8o/vendor/bundle/ruby/1.8/gems/libv8-3.11.8.3 for inspection.
Results logged to /Users/Eric/Development/par8o/vendor/bundle/ruby/1.8/gems/libv8-3.11.8.3/ext/libv8/gem_make.out
An error occured while installing libv8 (3.11.8.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.11.8.3'` succeeds before bundling.

The deal is with ruby 1.8.7. 这笔交易是红宝石1.8.7。 Probably you need this gem to run therubyracer. 可能你需要这个宝石来运行therubyracer。 And to make this work you need install therubyracer gem as follows: 要完成这项工作,您需要安装therubyracer gem如下:

RUBYOPT=-rrubygems gem install therubyracer

This will install both therubyracer and libv8 gems. 这将安装therubyracer和libv8宝石。

source: http://coderwall.com/p/y1djxq 来源: http//coderwall.com/p/y1djxq

In my case the compilation failed, due to issues with libtool. 在我的情况下,由于libtool问题,编译失败。 The error was libtool: unrecognized option '-static' when installing the libv8 gem. 错误是libtool: unrecognized option '-static'安装libv8 gem时libtool: unrecognized option '-static'

The problem was, that my macports-Installation was having a obviously non-working libtool. 问题是,我的macports-Installation有一个明显不起作用的libtool。 And the macports-Directory in $PATH were before the regular directories the wrong libtool was called. 并且$PATH中的macports-Directory在常规目录之前调用了错误的libtool。

Removing the macports-Directories from the PATH-Environmentvariable did the trick: the libtool from XCode was used and everything went fine. 从PATH-Environmentvariable中删除macports-Directories就可以了:使用了XCodelibtool ,一切都很顺利。

I had this issue and found a the solution here 我有这个问题,并在这里找到了解决方案

In short, install v8 yourself - if you have home-brew you can run 简而言之,自己安装v8 - 如果你有自酿啤酒,你可以运行

brew install v8

Then use the system v8 when installing 然后在安装时使用系统v8

gem install libv8 -- --with-system-v8

After I had this problem on OS X 10.7.5, the follow Gemfile entry worked for me: 我在OS X 10.7.5上遇到此问题后,以下Gemfile条目对我有用:

gem "libv8", '3.11.8.13'

> ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin11.4.2]

使用上面的RUBYOPT = -rrubygems建议对我有用,但我必须首先卸载现有的therubyracer和libv8 gems。

经过多次失败尝试各种方法后,我终于下载了Xcode,并且正如错误信息所暗示的那样,那就是诀窍

None of the above answers worked for me. 上述答案都不适合我。 This is what did: 这是做了什么:

gem install libv8 -v '3.11.8.3'
gem install therubyracer -v '0.11.0beta5'

ref: https://coderwall.com/p/s8ofka 参考: https//coderwall.com/p/s8ofka

My System: 我的系统:

OSX Mountain Lion
Ruby 1.9.3

First try and resolve the issue by using: 首先尝试使用以下方法解决问题:

RUBYOPT=-rrubygems gem install therubyracer

If the error persists, update your gems: 如果错误仍然存​​在,请更新您的宝石:

bundle update

Different gems require different versions of GCC, so this may or may not work for all gems, but these symlinks solved the problem for the json, eventmachine, and libv8 gems on Mountain Lion with Xcode 4.4 installed. 不同的宝石需要不同版本的GCC,因此这可能适用于所有宝石,也可能不适用,但这些符号链接解决了安装了Xcode 4.4的Mountain Lion上的json,eventmachine和libv8宝石的问题。

sudo ln -s /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 sudo ln -s /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2

sudo ln -s /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 /usr/bin/g++-4.2 sudo ln -s /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 /usr/bin/g++-4.2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM