33

I'm having big trouble in configuring Ruby and MySQL on MacOSX. Just a fact, I'm new on MacOSX and Ruby On Rails.

So, first I was having problems to install mysql2 gem, after get the gem installed I was trying developer a test, and when I tried start the WEBrick got this error saying that couldn't load a MySQL lib called "libmysqlclient.18.dylib". Googlin' about the error I saw that everyone was recommending using Ruby through RVM. I installed RVM and tried install ruby 1.9.3 and get this error:

ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.

I'm almost giving up learn Rails, setup a development environment shouldn't be that painful. On Windows I got no problems.

MaltMaster
  • 758
  • 1
  • 10
  • 25

6 Answers6

66

Unfortunately, you're trying Rails at a bit of a bad time. There's a lot of transition at the moment, as others have mentioned Xcode 4.2 was recently released and has a new compiler, also Ruby 1.9.3 came out.

I've been developing Ruby and Rails for some years now, but trying to get up and running again after installing Lion clean this week has been more problematic than in the past.

First, make sure RVM is up to date (as the issue should be fixed):

rvm get head

Then try installing like so:

CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

EDIT:

Note, working through my own issues I believe the first command probably fixed the problem. The second wouldn't have provided any benefit over:

rvm install 1.9.3

As on my clean install, /usr/bin/gcc-4.2 doesn't exist.

Also I wanted to add that I ended up compiling the older GCC manually for those situations where the new compiler fails. I followed this very informative blog post.

Delameko
  • 2,544
  • 21
  • 19
  • I installed the osx-gcc-installer(https://github.com/kennethreitz/osx-gcc-installer) in one of my previous tries, maybe that must did the trick to work. So I installed Ruby and RVM, in the week I'll test to see if everything is OK. – MaltMaster Nov 06 '11 at 06:09
  • 1
    rvm get head CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared COMBO WORKED – brian.clear Dec 04 '11 at 20:56
  • Thnxs! I had to follow your "very informative blog post" and manually compile gcc – jalagrange Dec 16 '11 at 18:12
  • You can also install gcc with this simple installer: https://github.com/kennethreitz/osx-gcc-installer – gdelfino Dec 16 '11 at 20:14
  • thanks! it was troubling with different xcode versions, default installs, different ruby versions etc. but rvm get head worked! thanks! – Sasha Feb 18 '12 at 22:36
  • Using gcc-4.2 and `--enable-shared` was my preferred method of installing old ruby 1.8.7 on Lion. Using `rvm install 1.8.7 --with-gcc=clang` is not fully supported, as stated elsewhere. – jrhorn424 Feb 27 '12 at 05:50
  • Just to clear up any confusion, the second command `CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared` does help. `rvm get head` alone wasn't enough to fix this for me! – Will Pragnell Feb 28 '12 at 18:52
  • rvm get head then CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --with-gcc=clang – pduey Mar 23 '12 at 17:51
  • Thanks! My issue was that I didn't have a non llvm based c compiler so the link to the blog post was the part that I needed. – spinlock Apr 06 '12 at 21:35
  • +1 for updating rvm, though it did blow all my gemsets away. No big seal since everything is set up using bundler. – superluminary Oct 24 '12 at 11:08
  • Running 'rvm get head' then 'CC=/usr/bin/gcc-4.2 rvm install 1.9.3-p362 --with-gcc=lang --enable-shared' worked. – wintondeshong Jan 03 '13 at 22:05
48

add --with-gcc=clang as a parameter:

rvm install ruby-1.9.3 --with-gcc=clang
Udo Held
  • 12,314
  • 11
  • 67
  • 93
Anno2001
  • 1,343
  • 12
  • 17
  • 2
    I'm try to install an older version of ruby to follow along with some 3 year old examples rvm install 1.8.6 --with-gcc=clang worked a charm, thanks – Edward Wilde Jul 25 '12 at 05:54
  • could install 1.9.3 no problem but anything older then that, would not go through. This helped me. Thank you @team-pannous – GnrlBzik Oct 22 '12 at 21:16
3

Did you install the latest Xcode from Mac Store?

here is a nice guide i followed to update my ruby/Rails to 1.9.2/3.0

guide

good luck

Cygnusx1
  • 5,329
  • 2
  • 27
  • 39
2

Part of the problem is that with Mac OS X 10.7 (Lion), Apple switched C compilers, and some things don't build well with the new (LLVM) compiler yet. See http://eddorre.com/posts/rails-ultimate-install-guide-on-os-x-lion-using-rvm-homebrew-and-pow for decent instructions (note: I haven't followed these exact instructions, but they're a pretty good summary of the things I did do to get Rails working on Lion).

Once you have the C compiler issue dealt with, everything else should be pretty effortless.

Bonus tip: avoid MySQL. PostgreSQL is better in nearly every respect.

Marnen Laibow-Koser
  • 5,959
  • 1
  • 28
  • 33
  • Also, you don't need Pow to get started. If you want to just follow the instructions for building Ruby, {My|Postgre}SQL, and Rails, that's fine. – Marnen Laibow-Koser Nov 03 '11 at 18:56
  • 1
    Followed the instructions and downloaded Ruby, after that RVM tried to install and got a error saying that is missing zlib headers, openssl and GNU development headers. Really, I'm coming from Windows and .NET, I having to compile the sources to simple start in a language is a little absurd to me. hehehehe – MaltMaster Nov 03 '11 at 19:15
  • 1
    What's absurd about building from source? In the Unix world, lots of things are available as precompiled binaries, but some things aren't. What *is* absurd is that the build process is hard, but blame that on a recent compiler change and packages that haven't quite caught up yet. – Marnen Laibow-Koser Nov 03 '11 at 19:35
  • Anyway, you should just be able to install the appropriate headers. It would help to see the exact error messages, though. – Marnen Laibow-Koser Nov 03 '11 at 19:36
  • as i stated in my response, installing the latest version of Xcode will solve your C Compiler issues. Did you do it? – Cygnusx1 Nov 03 '11 at 19:40
  • 1
    Marnen Laibow-Koser: How I said, I'm not used to that. The install.log file: http://pastebin.com/4UjUstK9 – MaltMaster Nov 03 '11 at 19:50
  • Try Ruby 1.9.2 (or 1.9.3) instead of REE. Do you have the same problem? – Marnen Laibow-Koser Nov 03 '11 at 19:54
  • Also, I've seen some info indicating that Xcode 4.2 may be problematic for building Ruby. Try 4.1. – Marnen Laibow-Koser Nov 03 '11 at 19:56
  • OK, you probably just need to specify some `ARCH_FLAGS`. But before you do that, have you tried Xcode 4.1? – Marnen Laibow-Koser Nov 03 '11 at 20:03
  • I need Xcode 4.2 because I'm developing iPhone apps. There's another way? – MaltMaster Nov 03 '11 at 20:03
  • You can use the system Ruby for now (it's adequate for Rails, though it's 1.8.7), or see if anyone's got 1.9 binaries available. Or https://github.com/kennethreitz/osx-gcc-installer might do the trick (see https://github.com/sstephenson/ruby-build/issues/62 ). – Marnen Laibow-Koser Nov 03 '11 at 20:09
  • At this point, you might want to ask the Ruby or Rails mailing list. – Marnen Laibow-Koser Nov 03 '11 at 20:11
2

Thanks Delamenko finally got it to work

SUMMARY FOR STACK OVERFLOW

I was trying to install SiriProxy on a clean Lion installation on Xcode from App Store

I kept getting errors like : The provided CC(/usr/bin/gcc) is LLVM based.

bash-3.2$ rvm install 1.9.3
ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.

After 2 days finally got it working with these two lines

http://stackoverflow.com/questions/8000145/ruby-rvm-llvm-and-mysql

bash-3.2$ rvm get head
bash-3.2$ CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

Before that I had tried every stackoverflow article on Ruby and Lion so doing these may have done some setup that helped the above 2 steps work:

Things I tried included:

Running Install Xcode.app (I had downloaded from App Store - running this does futher installation)

Installing

https://github.com/kennethreitz/osx-gcc-installer/downloads may help for installing GCC.

Set up CC in

more /Users//.bash_profile

bash-3.2$ more /Users/<USERNAME>/.bash_profile 
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export CC=/usr/share/TargetConfigs/bin/gcc

First line came from SiriProxy install instruction https://github.com/plamoni/SiriProxy

2nd line export CC never seemed to work. So dont add.

It had many versions each pointing I finally used CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

brian.clear
  • 5,277
  • 2
  • 41
  • 62
0

See Arkku's answer - I tried everything here first, then did what he said and all is well.

As of Lion 10.7.3, Xcode 4.2 and Ruby 1.9.3p0 it's what works.

Community
  • 1
  • 1
Adam Eberbach
  • 12,309
  • 6
  • 62
  • 114