2

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.

RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193

1 Answers1

2

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 i.e. 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.

Community
  • 1
  • 1
DataDao
  • 703
  • 6
  • 12
  • Thanks jwater, I updated my question to be more specific. I am wholly ignorant of how to tell Bundler to use a specific compiler. Any additional help you can offer would be enlightening, I have a feeling this question and your answer will help lots of people once Yosemite disseminates out there. – RubyRedGrapefruit Oct 19 '14 at 16:23
  • I just found that and was going to link back to it. It has saved me. Thank you very, very much. – RubyRedGrapefruit Oct 19 '14 at 16:53