“gem install therubyracer -v '0.10.2'” 在 osx Mavericks 上没有安装

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19630154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:57:38  来源:igfitidea点击:

"gem install therubyracer -v '0.10.2'" on osx mavericks not installing

ruby-on-railsmacosgemtherubyracerosx-mavericks

提问by user2711889

Trying to install therubyracer on mavericks using "gem install therubyracer -v '0.10.2'" but i am getting the following error:

尝试使用“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

can anyone help me figure out how to get this gem to work? I have the command line tools installed.

谁能帮我弄清楚如何让这个宝石工作?我已经安装了命令行工具。

回答by Julian Popov

If you decide to use a newer therubyracergem version, you will no longer have this problem

如果您决定使用较新的therubyracergem 版本,您将不再有此问题

Otherwise:

除此以外:

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

回答by damianmr

So I finally got it working after some struggling... thanks to Simon and Alvaro.

因此,经过一番挣扎,我终于让它工作了……感谢 Simon 和 Alvaro。

I have one thing to add though, using the flag --with-system-v8 did not work for me... So i removed my system v8 with

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

brew uninstall v8

brew uninstall v8

And the run

和运行

gem install libv8

gem install libv8

If you have already run gem install libv8with the system v8 flag be sure to uninstall that gem version (do it by running gem uninstall libv8). The important thing is that you shouldn't use the one provided by brew, it does not seem to work in Mavericks (it gets installed well and bundler will report that your bundle is complete, but your app will fail when it tries to use v8).

如果您已经gem install libv8使用 system v8 标志运行,请确保卸载该 gem 版本(通过运行来完成gem uninstall libv8)。重要的是你不应该使用 brew 提供的那个,它似乎在小牛队中不起作用(它安装得很好,bundler 会报告你的包已经完成,但是当它尝试使用 v8 时你的应用程序会失败)。

To summarize the answer, doing the following worked for me:

总结答案,执行以下操作对我有用:

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

回答by Alvaro

I had the same problem, this works for me:

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

therubyracer (0.10.2) & libv8 (3.3.10.4)

therubyracer (0.10.2) & libv8 (3.3.10.4)

First of all:

首先:

  • brew install apple-gcc42
  • you must link all the binary files of the compilers (gcc, cpp, g++) to /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/<compiler>
  • brew install apple-gcc42
  • 您必须将编译器 ( gcc, cpp, g++) 的所有二进制文件链接到/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/<compiler>

After, you could try this:

之后,你可以试试这个:

  • brew install v8
  • gem install libv8 -v '3.3.10.4' -- --with-system-v8
  • gem install therubyracer -v 'therubyracer'or bundle installinto the directory of the rails project.
  • brew install v8
  • gem install libv8 -v '3.3.10.4' -- --with-system-v8
  • gem install therubyracer -v 'therubyracer'bundle install进入 rails 项目的目录。

回答by Simon

I just had the same problem and one solution is currentlyto use apple-gcc42instead of clangto compile both gems :

我刚刚遇到了同样的问题,目前一种解决方案是使用apple-gcc42而不是clang来编译两个 gem:

brew install apple-gcc42

And then you have the choice between doing some symlinks in /usr/bin for {gcc,g++,c++} binaries :

然后你可以选择在 /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

In fact g++should be enough.

事实上g++应该足够了。

Or...you could export CC/CXX/CPP environment variables with paths corresponding to the binaries created by homebrew. That's surely a cleaner workaround.

或者...您可以导出 CC/CXX/CPP 环境变量,其路径与自制软件创建的二进制文件相对应。这肯定是一个更清洁的解决方法。

A third solution is to download Xcode 4.6.3 and install it in the Applicationsfolder. Then, enter in the terminal:

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

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

Once the gem has been installed you can switch back to Xcode 5.0 :

安装 gem 后,您可以切换回 Xcode 5.0:

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

回答by M. Scott Ford

I found a workaround that worked without installing apple-gcc42.

我找到了一种无需安装 apple-gcc42 即可工作的解决方法。

This will work if the error message you're getting looks like this:

如果您收到的错误消息如下所示,这将起作用:

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'

Then you should be able to do the following:

那么你应该能够做到以下几点:

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

Source: https://github.com/cowboyd/therubyracer/issues/277#issuecomment-27734348

来源:https: //github.com/cowboyd/therubyracer/issues/277#issuecomment-27734348

回答by jshkol

As suggested in many answers, the easiest thing to do is to compile The Ruby Racer native extensions with Apple GCC 4.2 (instead of the version installed with Xcode).

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

If you're using MacPorts you shouldn't have to manually deal with setting up symbolic links for the GCC binaries. The port selectcommand does it for you. If you haven't updated MacPorts since installing Mavericks, do a sudo port selfupdate. With MacPorts up-to-date, try the following:

如果您使用 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

In general this procedure (sudo port select gcc [version]) will work any time you want to use a specific GCC version instead of the one installed by Xcode (Apple LLVM v5 for 10.9 Mavericks/Xcode 5).

通常,sudo port select gcc [version]只要您想使用特定的 GCC 版本而不是 Xcode 安装的版本(Apple LLVM v5 for 10.9 Mavericks/Xcode 5),此过程 ( ) 都可以使用。

回答by Eugene

I manage to install therubyracer 0.12 and libv8 3.16.14.3 on ruby 2.0.0p353 and os x 10.9

我设法在 ruby​​ 2.0.0p353 和 os x 10.9 上安装了 therubyracer 0.12 和 libv8 3.16.14.3

libv8 requires gcc42

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 requires later gcc

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

use bundleinstead of gem install therubyracer

使用bundle代替gem install therubyracer

回答by Travis

This should be a failsafe and clean way (no symlinks) to to install therubyracer for anyone having trouble.

这应该是为遇到问题的任何人安装 therubyracer 的一种故障安全和干净的方式(无符号链接)。

Taken from: gem install therubyracer -v 0.11.4 fails on OS X 10.10

取自:gem install therubyracer -v 0.11.4 在 OS X 10.10 上失败

install Xcode (if you don't already have one of these versions) 6.1.1, 6.2-beta or 6.3-beta and (this one is needed) 4.6.3

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

gem uninstall libv8if you haven't already done so

gem uninstall libv8如果你还没有这样做

switch to Xcode 4.6.3

切换到 Xcode 4.6.3

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

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

gem install libv8 -v '3.11.8.17'Or whichever version is tied to your version of therubyracer

gem install libv8 -v '3.11.8.17'或者任何与您的 therubyracer 版本相关的版本

switch to Xcode 6.1.1, 6.2-beta or 6.3-beta (or if you want to try your current install of Xcode, adjust this line, I've confirmed all 3 of these work)

切换到 Xcode 6.1.1、6.2-beta 或 6.3-beta(或者如果您想尝试当前安装的 Xcode,请调整此行,我已确认所有 3 个工作)

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

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

gem install therubyracer -v '0.11.4'or the version you're trying to install.

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

回答by Javid Jamae

I had a nearly identical error when trying to install therubyracer 0.12.0 to get it to work with libv8. This worked for me:

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

回答by Moemars

I had this problem after upgrading from Mavericks to Yosemite. The issue was that I compiled my Ruby version with the old version of OSX.

从 Mavericks 升级到 Yosemite 后,我遇到了这个问题。问题是我用旧版本的 OSX 编译了我的 Ruby 版本。

If I ran

如果我跑

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

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

I would get x86_64-darwin-13instead of x86_64-darwin-14for Yosemite.

我会得到x86_64-darwin-13而不是x86_64-darwin-14优胜美地。

To re-install Ruby I

重新安装 Ruby I

  1. Completely removed old version: rvm remove ruby-2.1.1
  2. Re-installed from source (the --disable-binary doesnt use pre-compiled binaries and forces a build): rvm reinstall --disable-binary 2.1
  1. 完全删除旧版本: rvm remove ruby-2.1.1
  2. 从源代码重新安装( --disable-binary 不使用预编译的二进制文件并强制构建): rvm reinstall --disable-binary 2.1

Then I was able to run bundle installwith no errors after trying all the solutions above.

然后bundle install,在尝试了上述所有解决方案后,我能够无错误地运行。