“gem install therubyracer -v'0.10.2'”在osx小牛没有安装
试图安装therubyracer在特拉华使用“gem install therubyracer -v'0.10.2'”但我得到以下错误:
/Users/dennischen/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for main() in -lobjc... yes creating Makefile make compiling rr.cpp clang: warning: argument unused during compilation: '-rdynamic' rr.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ 1 warning generated. compiling v8.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_array.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_callbacks.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_context.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_date.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_debug.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_exception.cpp clang: warning: argument unused during compilation: '-rdynamic' v8_exception.cpp:10:16: warning: unused variable 'stack' [-Wunused-variable] static void* stack[20]; ^ 1 warning generated. compiling v8_external.cpp clang: warning: argument unused during compilation: '-rdynamic' v8_external.cpp:10:9: warning: unused variable 'references' [-Wunused-variable] VALUE references; ^ 1 warning generated. compiling v8_function.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_handle.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_locker.cpp clang: warning: argument unused during compilation: '-rdynamic' v8_locker.cpp:45:5: warning: control reaches end of non-void function [-Wreturn-type] } ^ v8_locker.cpp:85:5: warning: control reaches end of non-void function [-Wreturn-type] } ^ 2 warnings generated. compiling v8_message.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_object.cpp clang: warning: argument unused during compilation: '-rdynamic' v8_object.cpp:77:19: warning: unused variable 'proto' [-Wunused-variable] Handle<Value> proto(rr_rb2v8(prototype)); ^ 1 warning generated. compiling v8_script.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_string.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_template.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_try_catch.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_v8.cpp clang: warning: argument unused during compilation: '-rdynamic' compiling v8_value.cpp clang: warning: argument unused during compilation: '-rdynamic' v8_value.cpp:100:9: warning: unused function 'ToInt32' [-Wunused-function] VALUE ToInt32(VALUE self) { ^ 1 warning generated. compiling v8_weakref.cpp clang: warning: argument unused during compilation: '-rdynamic' linking shared-object v8.bundle clang: error: no such file or directory: '/Users/dennischen/.rvm/gems/ruby-1.9.3-p194@panini/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a' make: *** [v8.bundle] Error 1
任何人都可以帮我弄清楚如何让这个gem工作? 我有安装的命令行工具。
如果你决定使用一个更新的therubyracer
gem版本,你将不再有这个问题
除此以外:
brew tap homebrew/dupes # Thanks Tom brew install 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 brew uninstall v8 gem uninstall libv8 gem install therubyracer -v '0.10.2' # specify version
所以我终于在一番挣扎之后得到了工作……感谢Simon和Alvaro。
我有一件事要补充,但使用国旗–with-system-v8没有为我工作…所以我删除了我的系统v8
brew uninstall v8
和运行
gem install libv8
如果您已经使用系统v8标志运行gem install libv8
,请务必卸载该gem版本(通过运行gem uninstall libv8
来执行gem uninstall libv8
)。 重要的是,你不应该使用brew提供的,它似乎并没有在小牛(它得到安装好,bundler将报告你的包是完整的,但是你的应用程序将尝试使用V8时失败)。
总结答案,做以下工作对我来说:
brew install apple-gcc42 sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 /usr/bin/g++ sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 /usr/bin/cpp brew uninstall v8 gem install libv8 gem install therubyracer
我有同样的问题,这对我有用:
therubyracer(0.10.2)&libv8(3.3.10.4)
首先:
-
brew install apple-gcc42
- 你必须将编译器的所有二进制文件(
gcc
,cpp
,g++
)链接到/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/<compiler>
之后,你可以试试这个:
-
brew install v8
-
gem install libv8 -v '3.3.10.4' -- --with-system-v8
-
gem install therubyracer -v 'therubyracer'
或将bundle install
到rails项目的目录中。
我只是有同样的问题, 目前一个解决scheme是使用苹果gcc42而不是铛编译这两个gem:
brew install apple-gcc42
然后你可以select在/ usr / bin中为{gcc,g ++,c ++}二进制文件做一些符号链接:
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 /usr/bin/g++ sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 /usr/bin/cpp
其实g ++应该就够了。
或者…您可以导出CC / CXX / CPP环境variables与由自制程序创build的二进制文件相对应的path。 这当然是一个更清洁的解决方法。
第三个解决scheme是下载Xcode 4.6.3并将其安装到Applications文件夹中。 然后,在terminal中input:
sudo xcode-select --switch /Applications/Xcode4.6.3.app/Contents/Developer gem install therubyracer
一旦安装了gem,您可以切换回Xcode 5.0:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
我发现了一个解决方法,没有安装apple-gcc42。
这将工作,如果您收到的错误消息如下所示:
clang: error: no such file or directory: '/Users/mscottford/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a'
那么你应该能够做到以下几点:
brew install v8 bundle install # after failing create link from brew installed v8 to error location ln -s /usr/local/Cellar/v8/3.21.17/lib/libv8_base.x64.a /Users/mscottford/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a bundle install
资料来源: https : //github.com/cowboyd/therubyracer/issues/277#issuecomment-27734348
正如许多答案中所build议的,最简单的方法是使用Apple GCC 4.2(而不是使用Xcode安装的版本)编译Ruby Racer本机扩展。
如果您使用MacPorts,则不必手动处理为GCC二进制文件设置符号链接。 port select
命令为你做。 如果您在安装Mavericks之后还没有更新MacPorts,请执行sudo port selfupdate
。 使用MacPorts最新,请尝试以下操作:
# If you don't have it, install the port for Apple's GCC 4.2 sudo port install apple-gcc42 # OR # If you had apple-gcc42 already (before Mavericks), update it sudo port upgrade apple-gcc42 # Same result as manual symlinking of GCC in other answers sudo port select gcc apple-gcc42 && hash -r # Install therubyracer, will install libv8 gem dependency # *note* if you have any existing versions of these gems, remove them gem install therubyracer # Restore GCC to system default (optional) sudo port select gcc none && hash -r
一般来说,这个过程( sudo port select gcc [version]
)可以在任何时候使用特定的GCC版本,而不是由Xcode安装的版本(Apple LLVM v5,用于10.9 Mavericks / Xcode 5)。
我设法在ruby 2.0.0p353和os x 10.9上安装therubyracer 0.12和libv8 3.16.14.3
libv8需要gcc42
brew install v8 brew install apple-gcc42 sudo ln -sf /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc sudo ln -sf /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 /usr/bin/g++ sudo ln -sf /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 /usr/bin/cpp gem install libv8
therubyracer需要以后的gcc
brew install gcc49 sudo ln -sf /usr/local/Cellar/gcc49/4.9-20131110/bin/gcc-4.9 /usr/bin/gcc sudo ln -sf /usr/local/Cellar/gcc49/4.9-20131110/bin/g++-4.9 /usr/bin/g++ sudo ln -sf /usr/local/Cellar/gcc49/4.9-20131110/bin/cpp-4.9 /usr/bin/cpp
的Gemfile
gem 'therubyracer', :require => 'v8', :platforms => :ruby
使用bundle
而不是gem install therubyracer
这应该是一个安全和干净的方式(没有符号链接)来安装therubyracer有困难的人。
取自: gem install therubyracer -v 0.11.4在OS X 10.10上失败
安装Xcode(如果你还没有这些版本的话)6.1.1,6.2-beta or 6.3-beta(需要这个)4.6.3
如果你还没有gem uninstall libv8
,请gem uninstall libv8
切换到Xcode 4.6.3
sudo xcode-select --switch /Applications/Xcode4.6.3.app/Contents/Developer
gem install libv8 -v '3.11.8.17'
或者哪个版本与您版本的therubyracer绑定
切换到Xcode 6.1.1,6.2-beta或6.3-beta(或者如果你想尝试你当前安装的Xcode,请调整这一行,我已经确认了所有这些工作)
sudo xcode-select --switch /Applications/Xcode6.1.1.app/Contents/Developer
gem install therubyracer -v '0.11.4'
或者你正在尝试安装的版本。
当试图安装therubyracer 0.12.0来使它与libv8一起工作时,我有一个几乎相同的错误。 这对我工作:
$ brew upgrade gcc $ gem uninstall therubyracer $ gem uninstall libv8 $ gem install therubyracer -v '0.12.0' Fetching: therubyracer-0.12.0.gem (100%) Building native extensions. This could take a while... Successfully installed therubyracer-0.12.0 1 gem installed $ gem install libv8 -v '3.16.14.3' -- --with-system-v8 Fetching: libv8-3.16.14.3.gem (100%) Building native extensions with: '--with-system-v8' This could take a while... Successfully installed libv8-3.16.14.3 1 gem installed
从OSX Mountain Lion升级到OSX Mavericks时,我遇到了同样的问题。
从ruby-1.8.7-p354升级到ruby-1.8.7-375对我来说是个诡计。
也许试着从ruby 1.9.3-p194升级到rc1(1.9.3现在是p484以上)
假设你使用rbenv:
rbenv install 1.9.3-rc1 rbenv rehash rbenv global 1.9.3-rc1 bundle install
从小牛升级到优胜美地后,我遇到了这个问题。 问题是我编译我的Ruby版本与旧版本的OSX。
如果我跑了
ruby -rubygems -e 'puts Gem::Platform.new(RUBY_PLATFORM)'
我会得到优胜美地的x86_64-darwin-13
而不是x86_64-darwin-14
。
重新安装Ruby I
- 完全删除旧版本:
rvm remove ruby-2.1.1
- 从源重新安装(–disable-binary不使用预编译的二进制文件,并强制构build):
rvm reinstall --disable-binary 2.1
然后,我尝试了上面的所有解决scheme后,运行bundle install
,没有任何错误。
我做的是在osx小牛队:
git clone git@github.com:cowboyd/therubyracer.git
然后:
gem build therubyracer.gemspec gem install therubyracer-0.12.1.gem
这个过程下载了一个libv8的二进制版本并安装它。