While installing ruby on Mac Mountain Lion, I get the following error:
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-1.9.3-p385.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Fetching yaml-0.1.4.tar.gz to /Users/alex/.rvm/archives
Extracting yaml to /Users/alex/.rvm/src/yaml-0.1.4
Configuring yaml in /Users/alex/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/alex/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/alex/.rvm/usr
Installing Ruby from source to: /Users/alex/.rvm/rubies/ruby-1.9.3-p385, this may take a while depending on your cpu(s)...
ruby-1.9.3-p385 - #downloading ruby-1.9.3-p385, this may take a while depending on your connection...
ruby-1.9.3-p385 - #extracted to /Users/alex/.rvm/src/ruby-1.9.3-p385 (already extracted)
ruby-1.9.3-p385 - #configuring
ruby-1.9.3-p385 - #compiling
Error running 'make', please read /Users/alex/.rvm/log/ruby-1.9.3-p385/make.log
There has been an error while running make. Halting the installation.
Looking at the make.log file:
[2013-02-07 19:58:28] make
CC = clang
LD = ld
LDSHARED = clang -dynamic -bundle
CFLAGS = -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -pipe
XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/Users/alex/.rvm/usr/include -I. -I.ext/include/x86_64-darwin12.1.0 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
regparse.c:582:15: error: implicit conversion loses integer precision: 'st_index_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
1 error generated.
make: *** [regparse.o] Error 1
I have installed latest Xcode 4, and also tried the workaround of issue #168; no success.
I came across this issue while searching because I was experiencing the exact same issue while using rvm to install ruby-1.9.3-p385.
You do not need to uninstall Xcode. If you have Xcode installed, and you are using Homebrew, you can just do the following:
$ brew tap homebrew/dupes
$ brew install apple-gcc42
This does look like an error in Ruby's onig_number_of_names function. The num_entries field in the st_table of type st_index_t which is ultimately unsigned long, but onig_number_of_names returns int.
Without uninstalling Xcode or installing apple-gcc42, just turning off the -Werror will do: CFLAGS="-Wno-error=shorten-64-to-32" rvm install ...
CFLAGS="-Wno-error=shorten-64-to-32" rvm install ...
Just do this:
It solves my error.
It solved my problem too.
It is said that gcc shipped with Xcode 4.x (which is actually llvm-gcc) is buggy: sstephenson/ruby-build#290 (comment)
Maybe it's not right to do export CC=gcc.
export CC=gcc just sets it for that terminal session. if you want to just even use it for this use case only:
CC=gcc rvm install 1.9.3
which worked for me. no need to un-install xcode