Using rvm, ruby 1.9.3, and attempting to use gcc, I couldn't get Ruby to build cleanly with yaml. While there are a variety of hacks to get yaml compilation to work, none of them seemed to work with rvm. I was troubleshooting late at night and I didn't retain my errors, so I'm working from memory here -- I would appreciate if someone else with a clean environment could test these steps.
Using the --with-gcc=clang
solution produced the mildly infamous error about the yaml parser:
It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.
Since I need yaml for what I'm going to be doing, and libyaml compiled fine when not being run by rvm, and I even had it installed in /usr/lib after building it by hand, I can't understand why rvm couldn't find and use that version of libyaml, even with the --shared-libs
option.
Using CC=/usr/bin/gcc rvm install 1.9.3
produced errors. In the .rvm/log/ruby-1.9.3-p385/configure.log, I found the following:
configure: error: C compiler cannot create executables
See `config.log' for more details
That error was also present in .rvm/log/libyaml-0.14/configure.log.
The solution for me ended up being to run the rvm command with sudo. Running a compile as root seems to remove Apple's GCC toolchain's disapproval of users doing anything as dirty as compiling software.
So sudo CC=/usr/bin/gcc rvm install 1.9.3 --disable-binary
gave me a clean compile of ruby+yaml in the rvm folder. I then needed to sudo chown -R username ~/.rvm && sudo chgrp -R staff ~/.rvm
to get things back in my user and running with my permissions.
I do not recommend compiling things as root, as I see it as a security risk (especially with the vulnerabilities found in the ruby stack and rubygems.org recently) -- but this produced a clean installation of ruby under rvm and might help someone with more talent or time figure out the root cause of the issue with Apple's gcc.