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

标签 ruby ruby-on-rails-3 v8 osx-mountain-lion

我一直在为这个问题绞尽脑汁。我已遵循几篇相关帖子中的建议,但无济于事。

我从全新安装的 Mountain Lion 开始,安装了命令行工具,并根据我发现的其他一些关于通过 Homebrew 安装 gcc-4.2 并添加符号链接(symbolic link)的帖子成功安装了 Ruby 1.8.7/usr/bin/gcc-4.2.

但是,现在我无法成功安装 libv8。下面的错误是我从现有建议中得到的。

任何额外的输入?

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.

最佳答案

与 ruby​​ 1.8.7 交易。可能您需要这个 gem 来运行 ruby​​racer。为了完成这项工作,您需要按如下方式安装 therubyracer gem:

RUBYOPT=-rrubygems gem install therubyracer

这将同时安装 therubyracer 和 libv8 gems。

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

关于ruby - 如何在新安装的 Mountain Lion 上安装 libv8 ruby​​ gem?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11731600/

相关文章:

ruby - 在 Ruby 测试中避免 protected 级别的访问器和相等方法

ruby - 合并 nanoc 中的项目

node.js - 将 null 参数传递给 v8 回调

ruby-on-rails - Rails 3 - 没有要加载的文件 - openssl

javascript - 将 C++ 函数绑定(bind)到 V8 时调用 SetAccessor 时出错

javascript - 函数和对象之间的差异及其如何影响性能

ruby - 在 Ruby DBI 中连接到远程数据库

ruby-on-rails - RoR top100 照片

ruby-on-rails - 如何在 Ruby 中构建 JSON 代码

ruby - 在类变量、rake 任务和 cron 上使用互斥锁的 Rails