简体   繁体   中英

Is it possible to install gems with Bundler and tell it to use a specific compiler for a specific gem?

I am unable to install my gem bundle on my new Mac running Yosemite, because one gem only installs with the C compiler that shipped with the OS, while another requires the C compiler from Homebrew.

I am unable to work at all simply because of this error that the supposedly new gcc version 4.9.1 has:

cc1: error: -Werror=shorten-64-to-32: no option -Wshorten-64-to-32

I don't understand what this error means, nor how to tell the compiler to ignore it. Or even it that's possible

My specific situation is that running bundle install fails on the v8 gem:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/me/.rbenv/versions/2.1.0/bin/ruby extconf.rb 
creating Makefile
Compiling v8 for x64
Using python 2.7.6
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);

The g++ compiler that ships with the new version of XCode gives this as the version:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

So, 4.2 is pretty old. If I could just configure that one gem to build with the Homebrew gcc , which is 4.9.1, I would think it would work.

I tried setting my CC and CXX variables to the Homebrew gcc , but then the Nokogiri gem would not install with the first error message above. So many more gems installed with the Yosemite cc that maybe leaving that there is the best route. I don't know.

well using bundle config you can pass compiler flags. A little more info would be helpful in giving you a better answer.

see: http://bundler.io/man/bundle-config.1.html

I just found this: How to install therubyracer gem on 10.10 Yosemite? this will give you libv8 and then v8 should compile and gem install. While looking into this issue I found tons of problems around Yosemite and clang/gcc, etc inluding this fix for nokogiri: Installing Nokogiri on OSX 10.10 Yosemite

Basically, from what I gather the yosemite gcc compiler is too outdated (the original error means the compiler doesn't recognize the given compile option ie the feature doesn't exists in gcc 4.2). The best solution I think would be to install a newer gcc via homebrew and setup paths etc so gem installs only use the homebrew version.

Hope those links help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM