Ruby, RVM, LLVM and MySQL - ruby-on-rails

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.

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.

add --with-gcc=clang as a parameter:
rvm install ruby-1.9.3 --with-gcc=clang

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

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.

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

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.

Related

Trying to get Ruby/Rails installed on OSX Mountain Lion

This is my first question please be nice.
I've been trying to get my hands dirty with ruby/rails for a small coding project. I have Mountain Lion, and have been trying to use various techniques i've found on stackoverflow, and across the interwebs. It's not going so great! Nothing works of course. I have the system version of Ruby (1.8.7) as of now, and a bunch of broken junk from trying and failing to install Ruby!
When I install Rails via gem install, it sat for awhile... I finally learned to use -V, and noticed everything was returning back 302, and this takes forever, and finally it installs -- I get this output when I try to run rails -v
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:230:in `activate': can't activate rack (~> 1.4.5, runtime) for ["actionpack-3.2.13", "railties-3.2.13"], already activated rack-1.5.2 for ["rack-ssl-1.3.3", "railties-3.2.13"] (Gem::LoadError)
It looks like some dependencies are broken? Anyhow I'm now trying to use RVM now to get another version of ruby and setup grails with brew, This is telling me that I need a newer version of ruby to install anything pretty much?? Here is the output.
rvm install 1.9.2-head
Installing requirements for osx, might require sudo password.
Skipping brew update make sure your formulas are up to date.
Cowardly refusing to continue, please read 'rvm autolibs'.
To proceed rvm requires a ruby-1.9|ruby-2 compatible ruby is installed.
We attempted to install ruby automatically but it failed.
Please install it manually (or a compatible alternative) to proceed.
-- I am getting os frustrated here, please throw me a bone and help me out --- If I have to have to I'll setup a linux vm just to get rails running -- yet I prefer working on my mac.
Please any advice?? I just want a working version of Rails 3 on my Mac this is allThanks in advance
Please go through www.railsinstaller.org for detailed installation and setup process. This guide should answer all of your questions.
Have you tried this tutorial http://net.tutsplus.com/tutorials/ruby/how-to-install-ruby-on-a-mac/
The tutorial includes all the errors you may come across during the installation.
According to this tutorial Ruby on Rail comes with the mac out of the box.
Have you tried JewelryBox? It provides a painless install method for rvm and a great little gui that helps you monitor the size of your gem sets, and installs of ruby. Along with helpful reminders to upgrade rvm. I resisted at first using it, because using a GUI made me feel like a noob, but it really is a great little tool, that makes for super easy installs of ruby, and rvm, and consequently rails.
http://jewelrybox.unfiniti.com/

Updating OpenSSL on OSx 10.8.3 Mountain Lion

Okay, so I have a fresh install and a clean slate...
What is the proper way to update OpenSSL from scratch on OSx 10.8.3?
Nothing is installed yet, but after I can get OpenSSL updated to v1+ I usually go with the standard: RailsInstaller.org ..... or should I be doing Homebrew/RVM first to setup rails?
Things like http://railsapps.github.com/rails-composer/ have issues without the updated OpenSSL and their recommendations don't seem to to the trick. http://railsapps.github.com/openssl-certificate-verify-failed.html
I have tried many ways without luck. Lot's of discussion/suggestions out there but would like to get it right one the first time without messing anything else up this time. Is it maybe that there is a line that requires sudo? If we can get a solid answer I'd like to get it out there to the rest of the community.
System: 15" MacBookPro Retina (2013) with OSx 10.8.3 Mountain Lion
A little late to the party...but the following non-rvm approach works for me:
pull and unzip sources from http://openssl.org/
./Configure darwin64-x86_64-cc
make
make test
sudo make install
This will put the executable in /usr/local/ssl/bin/openssl, so add this to your path (e.g. in .bash_profile:
export PATH="/usr/local/ssl/bin:$PATH"
And you may need to recompile ruby in order to pick up the changes.
Use RVM 1.19:
\curl -L https://get.rvm.io | bash -s stable --ruby --autolibs=enable
It will use existing package manager (fallback to Homebrew), install all requirements for ruby and ruby itself, right now it is MRI Ruby 2.0.0-p0
Follow instructions given from the installer, then:
rvm use ruby
ruby -v

OSX Ruby Error when starting a Rails scaffolding: Could not load OpenSSL

I had been racking my head on this for far too long.
I am installing ruby via RVM. I had no troubles while installing Ruby. The issue come with using openssl with anything in ruby i have tried the what seems to be the standard solution of installing RVM openssl package and reinstalling Ruby with --with-openssl-dir.
I have tired every combination of gcc-4.2 vs llvm-gcc (from Xcode). Homebrew openssl vs RVM openssl. Several versions of Ruby 1.9.3.
I get this error message when running 'rails new projectName'
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
RVM are available at rvm.io/packages/openssl.
I have edited the Gemfile and I am able to run the 'bundle install' however after that point, when I go to start the server 'rails s', I get the dreaded 'cannot load such file -- openssl'. This has shown up during a couple for the reinstalls as well but the latest mix of using Homebrew openssl and readline doesn't give these errors during install, just when I get to starting the server.
I will be happy to post any config files or setting that are needed to help diagnose the problem. I am using the stable release of RVM and on OS X 10.8.2. I am new to Mac (this is the second day) and have some basic unix experience, so kid glove explanations are welcome.
Try to change the first line in your Gemfile from
source 'https://rubygems.org' to source 'http://rubygems.org'
I think this could solve your problem.

Ruby version did not get updated to 1.9.x

I installed ruby as per instructions given here but when I do ruby--version then it still shows 1.8.7. How do I make sure I use newly installed Ruby?
I would suggest you to use RVM (Ruby Version Manager). You may find a full installation guide here:
http://ryanbigg.com/2011/06/mac-os-x-ruby-rvm-rails-and-you/
If you get an error such as "ERROR: Error running ' ./configure...." after executing rvm install e.g.
rvm install 1.9.3
Then you may try to install it like this:
rvm install 1.9.3 --with-gcc=clang
Note: in the guide this possible error is not described
Did you properly setup your PATH? What's the output of echo $PATH? /usr/local/bin has to come first they way this tutorial sets up things. You see that everything worked right when which ruby displays /usr/local/bin/ruby.
Personally I'd recommend using a tool for managing Ruby versions though. RVM still seems to be the most popular choice, I prefer the combination of rbenv and ruby-build.

Running Ruby from usr/bin instead of usr/local/bin?

So I was following the steps on Hivelogic to get ruby on rails setup on my machine. After compiling and installing, I used the which ruby command to double check it installed in the right place. It did not. I was able to install the Rails and MySQL gems though, but both POW and localhost:3000 don't work.
Is there anything wrong with having it in the usr/bin directory instead of usr/local/bin? My usr/local/bin is practically empty, but usr/bin has a ton of files in it.
Edit: I reinstalled ruby to usr/local/bin but now Rails won't install. Is it a problem that it's already installed in usr/bin?
That page is a few years old. The current best practice for Mac and Linux is to use rvm. You can see, even Hivelogic uses rvm now (though I'm not sure how I feel about installing it system wide).
Anything that recommends installing from source as the first option instead of a last-resort fallback is probably bad advice. It's better to install using a package manager like MacPorts or Homebrew both of which have current versions of Ruby 1.8 and 1.9.
MacPorts installs everything in /opt specifically to avoid conflict with system files. From time to time Apple will distribute an update that patches ruby and this can mess up anything you have in the way of dependencies if you've been using a modified /usr/bin/ruby. Generally the system ruby is supposed to be left as-is.
You can replace the "compile ruby" step with an installer like that and save yourself a lot of trouble in the future. Just be sure to have /opt/local/bin as one of the first items in your PATH just as you would for other solutions.
Since installing Ruby and Rails and some kind of database can be a confusing process, it seems like there should be a meta-installer to help you through the process.
So I finally managed to get rails installed in the correct spot. I had to change the line in my .profile to export PATH="/usr/local/bin:$PATH" and then do a sudo gem update --system after installing rubygems before rails could actually be installed.
RVM and Homebrew did not help at all.
EDIT: Since people have a problem with this answer, I'm giving an update. I have since installed RVM and am liking it, but only because I have a friend I ask all my questions to, as RVM is really confusing if you're not used to doing a lot on the command line. I needed help from him to install it because I didn't have any of the bash files, and thought they were hiding somewhere. If you're missing the bash files, just create them yourself. This took a long time to get working, but now I apparently have it setup right.

Resources