17

I've just upgraded to osx mavericks, and I want to install ruby 2.0, but I'm getting configure: error: cannot run C compiled programs. errors.

I update rvm with rvm get stable and then type rvm install 2.0.0 and get an error directing me to a log file. The log file contains:

configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... x86_64-apple-darwin13.0.0
checking host system type... x86_64-apple-darwin13.0.0
checking target system type... x86_64-apple-darwin13.0.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/Users/mattroberts/.rvm/src/ruby-2.0.0-p247':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

So, I tried listing the versions I do have. It tells me i have 1.9.3-p392 so I uninstall that one and re-install to see if that works - same error.

Do I need to re-install / update xcode, or is there another solution?

Thanks!

Matt Roberts
  • 26,371
  • 31
  • 103
  • 180
  • did you try this: http://stackoverflow.com/questions/8813889/rvm-ruby-installation-errors-mac/10593275#10593275 – knoight Oct 25 '13 at 16:17

7 Answers7

54

If you haven't upgraded Xcode after upgrading to Mavericks you should do so After that, open a command prompt and type:
xcode-select --install

This will install xcode command tools that have been deleted by OSX update. After that it should work okay.

Ann Kilzer
  • 1,266
  • 3
  • 16
  • 39
fsaravia
  • 735
  • 5
  • 5
  • 2
    Yay, updating xcode did the trick for me - I didn't need to `xcode-select --install` though – Matt Roberts Nov 12 '13 at 21:23
  • 2
    Oddly enough, I was on XCode 5 and I still needed to upgrade to 5.0.2 and still had to run the above command. – Hengjie Nov 18 '13 at 00:18
  • 2
    This was failing with a "not available" error for me. In case that happens to anyone else: http://apple.stackexchange.com/questions/110463/xcode-select-install-not-available-on-update-server – BenB Nov 25 '13 at 01:24
  • Is this only vlid for Mavericks? (10.8 says "xcode-select: Error: unknown command option '--install'.) – danieldekay Jan 26 '14 at 11:55
  • In addition to installing the command line tools with the above command I had to open Xcode. I guess this is required if Xcode has been installed but never run, which was the case for me. – Benjamin Hammer Nørgaard Jun 04 '14 at 20:34
  • 3
    all `xcode-select --install` does for me is `xcode-select: error: command line tools are already installed, use "Software Update" to install updates`. I had to – Antonio Jan 21 '15 at 22:36
29

The suggested solutions did not solve my issue (XCode at newest version, command line tools installed). I used rvm install ruby-1.9.3 --with-gcc=clang and that worked.

I thought rvm used to use clang for OSX by default. Not sure if I remember that wrong or something changed / this is no longer the best thing to do. Nevertheless it made the install work for me.

After Edu's comment, the github rvm issues page he referenced warns:

@marksands please be sure you know what you are duing, ruby 1.9.3 compiled with clang is not "safe", it can segfault, thread related issues to be expected, consider reinstalling ruby --with-gcc=gcc42 or just let rvm install gcc 4.6, only ruby 2.0.0 is fully compatible with clang

This issue points out issue with gcc46 on Mavericks:

The gem in question uses different language - not C/C++, it uses Objective-C - so it's not the compiler fault, you can build gcc-4.6 with support for Objective-C - it's just not done by default.

You have two options now, both start with uninstallig gcc-4.6 and then:

• Install apple-gcc42

• Install gcc-4.6 with --enable-objc

mmlac
  • 1,091
  • 1
  • 9
  • 24
  • also worked on Mavericks: rvm install ruby-1.8.7-p302 --with-gcc=clang – manitu Feb 01 '14 at 15:27
  • 1
    Installing with clang it's not safe. https://github.com/wayneeseguin/rvm/issues/2133 – Eduardo Jun 10 '14 at 01:03
  • 1
    brew install gcc46 --enable-objc is what worked for me. – SteveRawlinson Oct 27 '14 at 16:41
  • Note that in case of a failed installation, you'll already have brew's `gcc` installed (currently `gcc48`) and you'll need to first uninstall it before re-installing with `--enable-objc` or `--enable-all-languages`. – David Moles Feb 05 '15 at 17:44
8

this is supposed to be fixed, run:

rvm get head
rvm remove 1.9.3
rvm install 1.9.3

do not use extra flags

mpapis
  • 52,729
  • 14
  • 121
  • 158
  • 1
    I'm getting the following message in my configure.log: [2013-10-31 11:59:14] ./configure ... checking whether the C compiler works... no configure: error: in `/Users/Ann/.rvm/src/ruby-1.9.3-p448': configure: error: C compiler cannot create executables See `config.log' for more details – Ann Kilzer Oct 31 '13 at 17:03
  • what is in `/Users/Ann/.rvm/src/ruby-1.9.3-p448/config.log` – mpapis Oct 31 '13 at 23:07
  • I get the exact same error. Here is the config.log: https://gist.github.com/jaimeohm/7377415 – jaime Nov 08 '13 at 20:49
  • run `sudo port uninstall apple-gcc42` and then again the commands from answer – mpapis Nov 08 '13 at 21:18
3

What ended up working for me was installing XCode then RUNNING Xcode then trying to reinstall.

coderberry
  • 3,040
  • 3
  • 26
  • 28
1

Running

rvm_configure_env=('LDFLAGS=-L/opt/sm/pkg/active/lib' 'CFLAGS=-I/opt/sm/pkg/active/include' 'CPATH=/opt/sm/pkg/active/include')

Corrected my compiler issue in Mavericks

1

Solution:

unset SDKROOT

This worked for me. I hope it would for you too.

I tried to reinstall xcode along with xcode developer tools. Didn’t work. The same error.

Try to run with env -i bash —noprofile —norc to see whether your env vars are causing the issue to further investigate.

Inanc Gumus
  • 25,195
  • 9
  • 85
  • 101
0

Ran into the very same issue (on 10.8.5, all up to date). Ruby 2.0.0 installed fine, but not 1.9.3. This solution worked for me.

cd into the ruby path (found in config.log), then issue .configure (with all options, as found in config.log)

make
make install

Then:

rvm use 1.9.3 --create