Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Ruby on Mac OS X 10.8.2

I have referred to Installing Ruby on Rails - Mac OS Lion and followed Alain Beauvois's reply and got pretty much everything up. The only difference is I am using 1.9.3 instead of 1.9.2.

I have created .bash_profile and even made sure that is there by open -e .bash_profile and even added the line as stated by Alain Beauvois.

But what seems to be the problem now is I am getting this error:

Error running 'make', please read /usr/local/rvm/log/ruby-1.9.3-p374/make.log
There has been an error while running make. Halting the installation.

The referenced log contains this:

[2013-02-02 21:41:52] 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/usr/local/rvm/usr/include -I. -I.ext/include/x86_64-darwin12.2.1 -I./include -I.
    DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace  
    SOLIBS = 
compiling regparse.c
regparse.c:582:15: error: implicit conversion loses integer precision: 'st_index_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
    return t->num_entries;
    ~~~~~~ ~~~^~~~~~~~~~~
1 error generated.
make: *** [regparse.o] Error 1

I even tried

rvm -install ruby-1.9.3-p374

but still get the same error. I did get some weird errors before I got to this part but after I reran it with an addition of sudo in front of it, it worked. AFAIK, sudo = doing something with su permissions/privileges, right?

like image 743
Nil Avatar asked Feb 02 '13 13:02

Nil


People also ask

Does macOS have Ruby installed?

MacOS comes with a “system Ruby” pre-installed. If you see /usr/bin/ruby when you use the which command, it is the pre-installed macOS system Ruby. It's a bad idea to use the Mac system, Ruby, for developing Ruby applications (it's fine to use it for running utility scripts).

What is the latest version of Ruby for Mac?

The current stable version is 3.1. 2.


3 Answers

I had the exact same error, but am using brew instead of MacPorts. All I had to do was:

brew update
brew tap homebrew/dupes
brew install apple-gcc42
rvm get stable
rvm install 1.9.3-p374

I didn't have to set the CC environment variable as some instructions point out. HTH!

like image 62
Preston Lee Avatar answered Oct 17 '22 17:10

Preston Lee


If you are using rbenv and ruby-build instead of rvm, you have to do this:

env CC=gcc rbenv install 1.9.3-p392

If this doesn't work, try this:

# this export must be done before every new ruby build
export CC=gcc
# use the version you wish to install
rbenv install 1.9.3-p392

If it doesn't work, you need to install gcc first:

brew update
brew tap homebrew/dupes
# install apple-gcc, only once needed
brew install apple-gcc42

Until the ruby folks build a clang compatible ruby version, you have to export the CC variable before every build of a new ruby version

like image 25
Fa11enAngel Avatar answered Oct 17 '22 17:10

Fa11enAngel


Just found this. I think this is what you need to do.

First, if you haven't already, download MacPorts and install it. Then run the following two commands:

sudo port selfupdate
sudo port install apple-gcc42

Too get real UNIX GCC. Then, to install 1.9.3 run:

CC=/opt/local/bin/gcc-apple-4.2 rvm install ruby-1.9.3-p194 --enable-shared --without-tk --without-tcl

Which tells rvm to install Ruby using UNIX GCC without Tk or Tcl which require X11 (left out of OSX 10.8). If you want things like readline support, OpenSSL, etc., check out the above linked gist.

like image 18
Linuxios Avatar answered Oct 17 '22 19:10

Linuxios