“gem install therubyracer -v '0.10.2'” on

2020-01-25 12:05发布

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

/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.

12条回答
做自己的国王
2楼-- · 2020-01-25 12:32

I just had the same problem and one solution is currently to use apple-gcc42 instead of clang to compile both gems :

brew install apple-gcc42

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

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.

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

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

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 :

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
查看更多
该账号已被封号
3楼-- · 2020-01-25 12:41

I had the same problem, this works for me:

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>

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 install into the directory of the rails project.
查看更多
beautiful°
4楼-- · 2020-01-25 12:45

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).

If you're using MacPorts you shouldn't have to manually deal with setting up symbolic links for the GCC binaries. The port select command 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:

# 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).

查看更多
虎瘦雄心在
5楼-- · 2020-01-25 12:45

I had this same problem when I upgraded from OSX Mountain Lion to OSX Mavericks.

Upgrading from ruby-1.8.7-p354 to ruby-1.8.7-375 did the trick for me.

Maybe try upgraded from ruby 1.9.3-p194 to rc1 (1.9.3 is above p484 now)

assuming you use rbenv:

rbenv install 1.9.3-rc1
rbenv rehash
rbenv global 1.9.3-rc1
bundle install
查看更多
来,给爷笑一个
6楼-- · 2020-01-25 12:47

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

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
查看更多
对你真心纯属浪费
7楼-- · 2020-01-25 12:52

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:

$ 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
查看更多
登录 后发表回答