Gem mac 上安装 therubyracer -v '0.12.2' 安装问题

zhaopei · 2016年04月01日 · 最后由 iefsou 回复于 2016年04月24日 · 4246 次阅读

mac 上安装 therubyracer 0.12.2 依赖于 libv8 3.16.14.13 安装日志如下: Building native extensions. This could take a while... ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension.

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.2/ext/v8 /usr/local/opt/ruby/bin/ruby -r ./siteconf20160401-35470-1bzsbrk.rb extconf.rb checking for main() in -lpthread... yes checking for main() in -lobjc... yes checking for v8.h... yes checking for main() in -lv8... yes creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/usr/local/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0/therubyracer-0.12.2/mkmf.log

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.2/ext/v8 make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.2/ext/v8 make "DESTDIR=" compiling accessor.cc clang: warning: argument unused during compilation: '-rdynamic' In file included from accessor.cc:1: In file included from ./rr.h:4: /usr/local/include/v8.h:360:33: error: use of undeclared identifier 'nullptr' V8_INLINE MaybeLocal() : val_(nullptr) {} ^ /usr/local/include/v8.h:367:51: error: use of undeclared identifier 'nullptr' V8_INLINE bool IsEmpty() const { return val_ == nullptr; } ^ /usr/local/include/v8.h:371:29: error: use of undeclared identifier 'nullptr' out->val_ = IsEmpty() ? nullptr : this->val_; ^ /usr/local/include/v8.h:437:50: error: use of undeclared identifier 'nullptr' bool IsFirstPass() const { return callback_ != nullptr; } ^ /usr/local/include/v8.h:808:42: error: use of undeclared identifier 'nullptr' V8_INLINE Global() : PersistentBase(nullptr) {} ^ /usr/local/include/v8.h:833:18: error: use of undeclared identifier 'nullptr' other.val_ = nullptr; ^ /usr/local/include/v8.h:845:18: error: use of undeclared identifier 'nullptr' rhs.val_ = nullptr; ^ /usr/local/include/v8.h:1110:52: error: use of undeclared identifier 'nullptr' ScriptOrigin* origin = nullptr)); ^ /usr/local/include/v8.h:1113:30: error: use of undeclared identifier 'nullptr' ScriptOrigin* origin = nullptr); ^ /usr/local/include/v8.h:3242:36: error: use of undeclared identifier 'nullptr' return NewInstance(context, 0, nullptr); ^ /usr/local/include/v8.h:4457:57: error: use of undeclared identifier 'nullptr' experimental::FastAccessorBuilder* fast_handler = nullptr, ^ /usr/local/include/v8.h:4473:57: error: use of undeclared identifier 'nullptr' experimental::FastAccessorBuilder* fast_handler = nullptr); ^ /usr/local/include/v8.h:7292:27: error: use of undeclared identifier 'nullptr' if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty(); ^ In file included from accessor.cc:1: ./rr.h:358:39: error: no member named 'ScriptData' in namespace 'v8' class ScriptData : public Pointerv8::ScriptData { ~~^ ./rr.h:358:51: error: expected class name class ScriptData : public Pointerv8::ScriptData { ^ ./rr.h:360:21: error: no type named 'ScriptData' in namespace 'v8'; did you mean simply 'ScriptData'? inline ScriptData(v8::ScriptData* d) : Pointerv8::ScriptData(d) {}; ^~~~~~~~~~~~ ScriptData ./rr.h:358:7: note: 'ScriptData' declared here class ScriptData : public Pointerv8::ScriptData { ^ ./rr.h:360:54: error: no member named 'ScriptData' in namespace 'v8' inline ScriptData(v8::ScriptData* d) : Pointerv8::ScriptData(d) {}; ~~~~^ ./rr.h:360:65: error: expected class member or base class name inline ScriptData(v8::ScriptData* d) : Pointerv8::ScriptData(d) {}; ^ ./rr.h:360:65: error: expected '{' or ',' fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. make: *** [accessor.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.2 for inspection. Results logged to /usr/local/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0/therubyracer-0.12.2/gem_make.out

我在 debian 上安装没有一点问题,,,,,

试试这个方法:

brew tap homebrew/dupes 
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.12.2' # any specify version

有两种解决方法:

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

或者 brew install v8-315; brew link v8-315 --force did the trick for me.

今天我也遇到了这个问题,解决方法

brew tap homebrew/versions
brew install v8-315

gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315

bundle install

#4 楼 @rikiwong 这个我试一下,上面那两个试了不成功。

#4 楼 @rikiwong 多谢,用这个方法安装成功了,

#4 楼 @rikiwong 感谢,mac 10.11.4 通过此方法解决了问题。非常感谢。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号