The RVM is not working for me - ruby

I'm trying to use RVM to install ruby 1.9.2 on a Lion system with xcode 4.2. I'm new to ruby so I don't understand why this is not working. I'm reading Ruby on Rails 3 Tutorial as my install guide. However, book is not up to date as it relates to Lion. Can anyone point out what's going on and give exact instructions on what I need to do?

If you do a fresh install of Xcode 4.2, it does not come with GCC (it only comes with LLVM GCC). You should download: https://github.com/kennethreitz/osx-gcc-installer to get GCC.
Once Xcode is installed:
Install RVM (http://beginrescueend.com/rvm/install/)
Close terminal, open a new terminal (just in case).
Enter: rvm list known
You can install any of the rubys with: rvm install X (where X is the ruby)
If you're not sure about step 4, just do "rvm install ruby-1.9.2"
I think that'll work...

I don't have that book, but try following the official instructions: http://beginrescueend.com/rvm/install
EDIT: Tried to leave this as a comment to Ngan, but don't know how to format in comments. If that is indeed the issue (you'll know because you will be getting segfaults when you install gems), Xcode still comes with plain gcc, it just uses LLVM GCC by default. You can set the environment variable CC to use plain gcc:
rvm remove 1.8.7 # or whatever version is failing, just in case
CC=/usr/bin/gcc-4.2 rvm install 1.8.7

If you don't mind using homebrew, try this instructions: Installing Rails on OS X Lion with HomeBrew, RVM and Mysql

Related

Installing ruby 1.9.2 with RVM on Mountain Lion

I am trying to install ruby 1.9.2 using RVM and I cannot seem to get it to work. I have installed homebrew, GCC 4.2, X-Code command line tools, and I've made sure I have all the rvm requirements and that RVM is up to date. It just will not work. Here is a gist of what I am seeing in my terminal. Thank you very much.
Terminal:
https://gist.github.com/justinhenricks/5264924
Configure.log file:
https://gist.github.com/justinhenricks/5264973

Getting Ruby 1.8.7 installed on Mountain Lion (10.8)

I'm having a lot of trouble getting Ruby 1.8.7 installed on my clean install of Mountain Lion. I've looked around on Stack Overflow and don't see anything that specifically addresses this issue and hope that someone might have encountered this before.
I'm using the command line tools that can be downloaded with Xcode
I haven't had any problems installing Ruby 1.9.3 via RVM and HomeBrew. When I try to install 1.8.7 I get the following message after it tries to compile:
I first ran the command
rvm install 1.8.7
This gave me this error
The provided compiler '/usr/bin/gcc' is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.
After digging around a bit I tried
rvm install 1.8.7 --with-gcc=clang
Error running 'make ', please read /Users/paulzaich/.rvm/log/ruby-1.8.7-p370/make.log
There has been an error while running make. Halting the installation.
Ruby 'ruby-1.8.7-p370' was built using clang - but it's not (fully) supported, expect errors.
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to Ruby 1.9.3-194 which will have all of the latest security patches.
At this point I did some more searching and found something about needing compile my own readline. RVM Does Not Install Ruby 1.9.2 on Snow Leopard: 'Error running 'make '
This unfortunately seemed to corrupt my entire rvm install including 1.9.3. I tried to reinstall 1.9.3 and got the same errors I as I was getting with 1.8.7. I completely deleted RVM at this point and reinstalled. Had no problem installing 1.9.3 again.
I also tried updating all versions of rvm based off of this post RVM issue with Mountain Lion. No luck there either.
Update: I also tried using this walkthrough for REE 1.8.7 which recommended installing gcc-4.2. No luck unfortunately.
Update 2: I reference rvm requirements and installed the following packages
brew update
brew tap homebrew/dupes
brew install autoconf automake apple-gcc42
rvm pkg install openssl
So far so good. Then I referenced this post on needing to reference the GCC compiler. I determined that the links referenced might not be correct because I'm using homebrew? I found the compiler in my Cellar folder and used the following command
CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 rvm install 1.8.7
No luck. Same error messages as before.
I just figured it out! Please reference this question on SO
rvm can no longer install 1.8.7-p352 on Mac OS X Mountain Lion
rvm reinstall 1.8.7 --without-tcl --without-tk
Alternatively, try this installation order if you have Homebrew.
brew install tcl-tk
rvm reinstall 1.8.7
Just to follow up to Paul's post. I'm running OSX 10.8.2, had 1.9.3 install without issues, but 1.8.7-p370 also failed. I symlinked gcc-4.2:
sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2
...successfully ran:
brew install tcl
...but tk failed:
brewk install tk
If you're in the same spot, this command did the trick:
CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7 --without-tk
Latest Xcode provides only clang - not GNU gcc, you need to install gcc-4.2 to be able to compile Ruby 1.8.7 properly, following command will show available options:
rvm requirements
currently only ruby 1.9.3-p125 and later has limited support for clang, but this is limited support, and still errors can be found.

Why am I having trouble compiling Ruby 1.9.2 with RVM on Mac OS Lion?

I am having trouble installing Ruby 1.9.2 with rvm on Mac OS Lion.
It gets stuck in the compilation stage; I don't see any errors or output, but it will be stuck at the compilation message for hours upon hours. The miniruby process is still running and using quite a bit of CPU, but it just never finishes.
The only thing I can find in the logs is this message in the make.log:
<internal:prelude>:1: [BUG] Segmentation fault
Any ideas how I can get this to compile?
What version of xcode are you using?
rvm requirements has this little tidbit:
** Lion Users: Xcode Version 4.2.x for OS X Lion works only for ruby 1.9.3-p0 (or higher).
It currently fails to build several other rubies and gems, as well as several Homebrew and
Macports packages. Xcode Version 4.1 (4B110) works.
Xcode v4.1 is at: https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.1_for_lion/xcode_4.1_for_lion.dmg
It's also important to make sure your RVM is current. Run rvm get head to upgrade to the latest version.
It may be related to Lion trying to use llvm to compile instead of gcc. Try running the command like this CC=/usr/bin/gcc-4.2 rvm install 1.9.2 to use gcc.
Based on the information in this other answer: Why can't I install Rails on Lion using RVM?
First read the installation notes of rvm, Follow the link which helped me RVM on Mac

Ruby, rubygems and rails conflict with stock Mac OS X Leopard files

Ok guys, so I've been trying to install ruby on my mac for the past two days. What seems to be happening is that there's a conflict between the stock ruby, rubygems and rails from Mac OS X Snow Leopard and the ones I'm trying to install.
I'm using rvm to get the files, therefore I'm running rvm install 1.9.2. Installation seems to go normally, but when I run ruby -v, it shows me the old version (1.8.7). Same goes for rubygems. While rvm should installs it, when I run gem -v, old version is shown (1.3.5). \
This screenshot shows what I'm saying: http://cl.ly/2a3m1v0u331i272z2J22
Thank you.
Once you've installed RVM, you also need to tell you system that you want to use that version of Ruby. This is usually done via:
rvm use 1.9.2
However, when you open a new shell, it will revert back to the system default. If you want to set 1.9.2 as your default ruby, use:
rvm --default use 1.9.2
I suggest you look through the documentation a bit more to help you get the most out of RVM:
Basics: https://rvm.beginrescueend.com/rvm/basics/
Best Practices: https://rvm.beginrescueend.com/rvm/best-practices/
Check your PATH variable.
echo $PATH
/usr/local/bin should be before /usr/bin.
If not so - change it in your /Users/Your_name/.bash_profile

How to update Ruby to 1.9.x on Mac?

I have created a new user account on my mac and I am trying to update to the current version of ruby on it (1.9.2) from the snow leopard default of 1.8.7. Can somebody point me to tutorial or explain the best method to update Ruby on my mac from 1.8 to 1.9.2? Thanks
As The Tin Man suggests (above) RVM (Ruby Version Manager) is the Standard for upgrading your Ruby installation on OSX: https://rvm.io
To get started, open a Terminal Window and issue the following command:
\curl -L https://get.rvm.io | bash -s stable --ruby
( you will need to trust the RVM Dev Team that the command is not malicious - if you're a paranoid penguin like me, you can always go read the source: https://github.com/wayneeseguin/rvm ) When it's complete you need to restart the terminal to get the rvm command working.
rvm list known
( shows you the latest available versions of Ruby )
rvm install ruby-2.3.1
For a specific version, followed by
rvm use ruby-2.3.1
or if you just want the latest (current) version:
rvm install current && rvm use current
( installs the current stable release - at time of writing ruby-2.3.1 - please update this wiki when new versions released )
Note on Compiling Ruby: In my case I also had to install Homebrew Link to get the gems I needed (RSpec) which in turn forces you to install Xcode (if you haven't already) https://itunes.apple.com/us/app/xcode/id497799835 AND/OR install the GCC package from: https://github.com/kennethreitz/osx-gcc-installer to avoid errors running "make".
Edit: As of Mavericks you can choose to install only the Xcode command line tools instead of the whole Xcode package, which comes with gcc and lots of other things you might need for building packages. It can be installed by running xcode-select --install and following the on-screen prompt.
Examples: https://rvm.io/workflow/examples/
Screencast: http://screencasts.org/episodes/how-to-use-rvm
Note on erros: if you get the error "RVM is not a function" while trying this command,
visit: How do I change my Ruby version using RVM? for the solution.
I'll make a strong suggestion for rvm.
It's a great way to manage multiple Rubies and gems sets without colliding with the system version.
I'll add that now (4/2/2013), I use rbenv a lot, because my needs are simple. RVM is great, but it's got a lot of capability I never need, so I have it on some machines and rbenv on my desktop and laptop. It's worth checking out both and seeing which works best for your needs.
With brew this is a one-liner:
(assuming that you have tapped homebrew/versions, which can be done by running brew tap homebrew/versions)
brew install ruby193
Worked out of the box for me on OS X 10.8.4. Or if you want 2.0, you just brew install ruby
More generally, brew search ruby shows you the different repos available, and if you want to get really specific you can use brew versions ruby and checkout a specific version instead.
I know it's an older post, but i wanna add some extra informations about that.
Firstly, i think that rvm does great BUT it wasn't updating ruby from my system (MAC OS Yosemite).
What rvmwas doing : installing to another location and setting up the path there to my environment variable ... And i was kinda bored, because i had two ruby now on my system.
So to fix that, i uninstalled the rvm, then used the Homebrew package manager available here and installed ruby throw terminal command by doing brew install ruby.
And then, everything was working perfectly !
The ruby from my system was updated !
Hope it will help for the next adventurers !
I'll disagree with The Tin Man here. I regard rbenv as preferable to RVM. rbenv doesn't interfere drastically with your shell the way RVM does, and it lets you add separate Ruby installations in ordinary folders that you can examine directly. It allows you to compile Ruby yourself. Good outline of the differences here: https://github.com/sstephenson/rbenv/wiki/Why-rbenv%3F
I provide instructions for compiling Ruby 1.9 for rbenv here. Further, more detailed information here. I have used this technique with easy success on Snow Leopard, Lion, and Mountain Lion.
Dan Benjamin's Hivelogic article Installing Ruby, RubyGems, and Rails on Snow Leopard is the recommended place to go although the article is for 1.8, so here's a Ruby 1.9-specific install on Snow Leopard. Watch out for the 64-bit thing... either go all 64-bit 'fat' (as is - for example - Apache on OS X, which can cause problems with 32-bit libraries) or check any gems you're likely to use to make sure they're okay for 64-bit.
This command actually works
\curl -L https://get.rvm.io | bash -s stable --ruby
As previously mentioned, the bundler version may be too high for your version of rails.
I ran into the same problem using Rails 3.0.1 which requires Bundler v1.0.0 - v1.0.22
Check your bundler version using: gem list bundler
If your bundler version is not within the appropriate range, I found this solution to work: rvm #global do gem uninstall bundler
Note: rvm is required for this solution... another case for why you should be using rvm in the first place.
There are several other version managers to consider, see for a few examples and one that's not listed there that I'll be giving a try soon is ch-ruby. I tried rbenv but had too many problems with it. RVM is my mainstay, though it sometimes has the odd problem (hence my wish to try ch-ruby when I get a chance). I wouldn't touch the system Ruby, as other things may rely on it.
I should add I've also compiled my own Ruby several times, and using the Hivelogic article (as Dave Everitt has suggested) is a good idea if you take that route.

Resources