osx mavericks没有安装“gem install therubyracer -v'0.10.2”

时间:2013-10-28 08:33:28

标签: ruby-on-rails macos gem therubyracer osx-mavericks

尝试使用“gem install therubyracer -v'0.10.2'”在小牛上安装therubyracer但是我收到以下错误:

/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

任何人都可以帮我弄清楚如何使这个宝石工作?我安装了命令行工具。

12 个答案:

答案 0 :(得分:241)

如果您决定使用较新的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

答案 1 :(得分:16)

所以我终于在经历了一些挣扎之后才开始工作......感谢Simon和Alvaro。

我有一件事要补充,使用标志--with-system-v8对我不起作用...所以我删除了我的系统v8

brew uninstall v8

并且运行

gem install libv8

如果您已经使用system v8标志运行gem install libv8,请确保卸载该gem版本(通过运行gem uninstall libv8来执行此操作)。重要的是你不应该使用brew提供的那个,它似乎不适用于Mavericks(它安装得很好,捆绑器会报告你的捆绑包已经完成,但是你的应用程序尝试使用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

答案 2 :(得分:10)

我有同样的问题,这对我有用:

  

therubyracer(0.10.2)&amp; libv8(3.3.10.4)

首先:

  • brew install apple-gcc42
  • 您必须将编译器的所有二进制文件(gcccppg++)链接到/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项目目录。

答案 3 :(得分:7)

我遇到了同样的问题,一个解决方案目前使用 apple-gcc42 代替 clang 来编译这两个宝石:

brew install apple-gcc42

然后你可以选择在/ 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环境变量。这肯定是一个更清洁的解决方法。

第三种解决方案是下载Xcode 4.6.3并将其安装在 Applications 文件夹中。然后,输入终端:

sudo xcode-select --switch /Applications/Xcode4.6.3.app/Contents/Developer
gem install therubyracer

安装完宝石后,您可以切换回Xcode 5.0:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

答案 4 :(得分:6)

我发现了一种无需安装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

答案 5 :(得分:3)

正如许多答案中所建议的那样,最简单的方法是使用Apple GCC 4.2编译Ruby Racer原生扩展(而不是使用Xcode安装的版本)。

如果您使用的是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)时使用。

答案 6 :(得分:3)

我设法在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

答案 7 :(得分:3)

这应该是一种安全且干净的方法(没有符号链接)来为任何有麻烦的人安装therubyracer。

取自:gem install therubyracer -v 0.11.4 fails on OS X 10.10

安装Xcode(如果您还没有这些版本之一)6.1.1,6.2-beta或6.3-beta和(需要这一个)4.6.3

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,请调整此行,我已经确认了所有这3项工作)

sudo xcode-select --switch /Applications/Xcode6.1.1.app/Contents/Developer

gem install therubyracer -v '0.11.4'或您尝试安装的版本。

答案 8 :(得分:1)

在尝试安装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

答案 9 :(得分:0)

当我从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

答案 10 :(得分:0)

从小牛升级到约塞米蒂后我遇到了这个问题。问题是我使用旧版本的OSX编译了我的Ruby版本。

如果我跑了

ruby -rubygems -e 'puts Gem::Platform.new(RUBY_PLATFORM)'

我会为优胜美地获得x86_64-darwin-13而不是x86_64-darwin-14

重新安装Ruby I

  1. 完全删除旧版本:rvm remove ruby-2.1.1
  2. 从源代码重新安装(--disable-binary不使用预编译的二进制文件并强制构建):rvm reinstall --disable-binary 2.1
  3. 然后,在尝试了上述所有解决方案之后,我能够毫无错误地运行bundle install

答案 11 :(得分:-2)

我做的是对osx mavericks:

git clone git@github.com:cowboyd/therubyracer.git

然后:

gem build therubyracer.gemspec
gem install therubyracer-0.12.1.gem

此过程下载了libv8的二进制版本并进行了安装。