35

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?

Community
  • 1
  • 1
Nil
  • 361
  • 1
  • 3
  • 10
  • 1
    Did you read /usr/local/rvm/log/ruby-1.9.3-p374/make.log? – Gumbo Feb 02 '13 at 13:55
  • Just download this kit from http://railsinstaller.org/#osx. It includes everything you need to get started with ruby/rails development – saihgala Feb 02 '13 at 14:13
  • Too long to post here, so pastebin it is: http://pastebin.com/R5VY6HPw Just wondering, did any of my actions earlier caused any impacts to my Mac? Maybe change settings etc – Nil Feb 02 '13 at 14:14
  • @AshishSaihgal will try that solution. Would like to do everything fresh and just use the installer. Anything I can do to undo the changes I made? Thanks! – Nil Feb 02 '13 at 14:17
  • 1
    How about `rvm install 1.9.3`? just type version number. – utwang Feb 02 '13 at 14:18
  • That looks more like a Ruby bug. I think you should report it. – Linuxios Feb 02 '13 at 14:20
  • @Linuxios gosh, for a newbie, that really killed my spirit to try things out. Anyone have maybe a better way? (If there is any..) – Nil Feb 02 '13 at 14:24
  • @DuaneAdam: Yes. Don't try to install the absolute latest patch version. Try to install 1.9.3-p362. – Linuxios Feb 02 '13 at 14:25
  • @at2c that was the first thing I did. In the op, I said I even tried with "-p374" – Nil Feb 02 '13 at 14:26
  • By the way, this is one of the best written and best understood first questions I've ever seen. – Linuxios Feb 02 '13 at 14:26
  • I wrote an article about this, just 2 weeks ago: http://simonewebdesign.it/blog/how-to-setup-osx-for-ruby-on-rails/ – Simone Feb 02 '13 at 14:31
  • @Linuxios thank you, I am trying my best not to 'spam' and make my question easy to understand for the community and for me so that I can get my answers fast and correctly. By the way, still the same error. – Nil Feb 02 '13 at 14:33
  • @DuaneAdam: Hm. Try installing 192-p290 if you're ok with having 1.9.2 instead of 1.9.3. – Linuxios Feb 02 '13 at 14:34
  • @Linuxios some screenshots: i) http://i.imgur.com/vqLYpVu.png ii) http://i.imgur.com/mPkuhwj.png – Nil Feb 02 '13 at 14:37
  • Now I am getting `The provided compiler '/usr/bin/gcc' is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.` – Nil Feb 02 '13 at 14:39
  • @DuaneAdam: Wait one second. – Linuxios Feb 02 '13 at 14:42
  • @DuaneAdam just go and delete /usr/local/rvm directory if you installed it as root else delete $HOME/.rvm directory and then just use the installer I mentioned earlier. – saihgala Feb 02 '13 at 15:04

9 Answers9

31

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!

Preston Lee
  • 584
  • 1
  • 4
  • 10
  • Thanks, this was a big help - I didn't realize MacPorts and brew did the same general thing, and couldn't figure out why the "port" command wasn't working. Still not sure why port didn't work, but I'm glad it didn't, since my work uses homebrew. – Ethel Evans Feb 08 '13 at 18:45
  • Note to myself, It looks like i might not have accepted the xcode command line tools so I had to run `xcodebuild -license`, then read the 'rvm requirements' and found I had to `brew install autoconf automake apple-gcc42 libtool pkg-config openssl readline libyaml sqlite libxml2 libxslt libksba` – nevieandphil Mar 19 '13 at 10:11
20

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

Fa11enAngel
  • 4,690
  • 2
  • 39
  • 38
18

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.

Linuxios
  • 34,849
  • 13
  • 91
  • 116
  • Now 'stuck' at `attempting to fetch livm-3/1-3.1_6.darwin` My guess is it is downloading a big sized file. – Nil Feb 02 '13 at 14:55
  • Looks like it will take quite a long time to download and I need to go to bed for now. Will get back to you first thing in the morning. I'll let it download through the night. – Nil Feb 02 '13 at 15:00
  • Everything is done, took awhile to download. How do I know it is installed correctly or configured correctly? Thanks. – Nil Feb 02 '13 at 23:15
  • Genius. It works! Whatever would we do without Stack Overflow? I was struggling with ruby and homebrew updates on El Capitan and this was the final piece in the puzzle. – ED-209 Sep 27 '16 at 08:43
  • @Tokn: glad the answer was so helpful! – Linuxios Sep 27 '16 at 15:15
3

This also worked in rbenv on OSX 10.8.2 + XCode 4.6

$ export CC=gcc
$ rbenv install 1.9.3-p385 -v

But is also useful to know that homebrew can install another version of gcc if apple changes the command line tools of Xcode in the future.

wlads
  • 767
  • 7
  • 9
1

I just did (after installing XCode command line tools):

$ export CC=gcc
$ rvm install 1.9.3

And although it said "Ruby 'ruby-1.9.3-p374' was built using clang - but it's not (fully) supported, expect errors." - it worked.

Roman
  • 13,100
  • 2
  • 47
  • 63
1

This worked for me as well on ruby-1.9.3-p385 with no homebrew or Macports installed.

export CC=gcc
rvm install 1.9.3

Gave message "Ruby 'ruby-1.9.3-p385' was built using clang - but it's not (fully) supported, expect errors." after completing task.

stonefruit
  • 195
  • 1
  • 10
1

Just to add another answer to the list... I'm using ruby-install, and this is what worked for me:

CC=/usr/local/bin/gcc-4.2 ruby-install ruby 1.9.3-p0
bricker
  • 8,911
  • 2
  • 44
  • 54
0

I tried apple-gcc42 and CC=/usr/bin/gcc without any luck so I'm not sure if they are necessary. I'm using the rbenv manager and so this is what worked for me when trying to install 1.9.3-p385

brew install readline
CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.3-p385

Found it on this blog

cwd
  • 53,018
  • 53
  • 161
  • 198
0

For the record: Works for me with rbenv, ruby 1.9.3-p385, gcc48 (brew install gcc48) on Darwin Kernel Version 15.2.0. (there were lots of warnings during compilation that I ignored, ruby works fine so far).

I just had to set CC=gcc-4.8 before rbenv install 1.9.3-p385

Kashyap
  • 15,354
  • 13
  • 64
  • 103