How to update to Ruby 1.8.7 - ruby

I am new to Ruby, so bear with me. I've been trying to update my Ruby to 1.8.7 and just ran into many issues on my Mac OS X (10.5.7).
So really, how do you update to Ruby 1.8.7?
Thanks.

The simplest answer is "don't". Ruby 1.8.7 was an attempt to create bridging release between 1.8 and 1.9, and the consensus of the community was that this was not necessary, so there was little support for it before 1.9 was finalized. The general recommendation is either to stick with 1.8 (the version is supplied with OS X 10.5), or use Ruby 1.9.
MacPorts has packages for Ruby 1.8.7 and Ruby 1.9, so that is probably the easiest way to get newer versions of Ruby without any risk of modifying OS X itself.
UPDATE: As ajhit406 noted, RVM is now the best option, rather than MacPorts.

Have you tried the one click installer?
Edit: the one click installer look like no more maintained, try Rails Installer.

necromancing...
http://rvm.io/
Edit(mpapis): Ruby 1.8.7 is no more maintained by Ruby team and should not be used anymore.

Download and unpack the version of Ruby you want. We'll call the directory ruby_1.8.7 and assume it is in your home directory. Open a terminal window.
sudo cp -r ruby_1.8.7 /System/Library/Frameworks/Ruby.framework/Versions/1.8.7
cd /System/Library/Frameworks/Ruby.framework/Versions
sudo ln -sfh 1.8.7 Current

Related

How to use the gems of Ruby 2.1 in Ruby 1.9 in batch

I have both Ruby 1.9 and 2.1 installed in my computer. Now I am wanting to use several of the gems installed for Ruby 2.1 in Ruby 1.9. However, Ruby 1.9 can't find them.
I tried to solve this problem by setting the environmental variable RUBYLIB but since there were so many gems that needed to be used I can't do it one by one. Is there an easier way?
For example, one of the packages I would like to use in Ruby 1.9 is pango.
Its path is ~/ruby/lib/ruby/gems/2.1.0/gems/pango-2.2.0/
All of the packages installed for Ruby 2.1 can be found at ~/ruby/lib/ruby/gems/2.1.0/gems
Thanks you.
I'd suggest you use a manager like rvm (https://rvm.io/) or rbenv (https://github.com/sstephenson/rbenv) to avoid manually configuring your environment. I use rvm even when I have only one Ruby version installed.

Can RVM find versions of ruby it did not install?

I'm running os x lion. A version of ruby was installed when I installed the OS. I then installed RVM and then installed ruby 1.9.2 and made it the default for new shells.
Default Ruby (for new shells)
ruby-1.9.2-p290 [ x86_64 ]
What happend to the older version of Ruby that was already on my system and how can I remove it since RVM doesn't see it?
When I try to use the new hash syntax in code written in textmate or sublime text 2 it fails. When the same code is run in the shell it works. So how do I make ruby 1.9.2 the only ruby installed on my system?
You do NOT want to uninstall the system Ruby. It is required for a lot of applications (including RVM) to function properly.
If you want applications like Textmate or Sublime Text to use a different version of Ruby, you can update their individual configuration settings to set the path to the Ruby binary you wish to use.
Since those apps don't run ruby from the shell like you do they don't work seamlessly with RVM. Fortunately RVM's web site has instructions on integrating RVM with TextMate. You shouldn't have trouble applying the same process for Sublime Text 2 but if you do the web does not want for tutorials on the topic.
Also, RVM is not responsible for any ruby it didn't install. the only other ruby it gives access to is the system ruby, and there it doesn't do gemsets etc. (This is also due to systems like debian that specifically block off things like gem update --system so you don't poison the package that was installed. RVM protects from that as well)

What are the advantages of RVM on linux?

Please understand that I'm not trying to bash RVM. I would just like to understand why it's so popular in the Ruby community.
There appears to be two main reasons to use RVM - to manage/switch between different versions of Ruby, and to manage a specific gemset per project. However there seem to be much cleaner ways of achieving the same thing on linux:
I can install different ruby versions
from the repositories through the
regular package manager, or build
from source and install as a package.
I can switch between versions using
update-alternatives (on Debian, Ubuntu, Fedora at least).
I can use Bundler to manage sets of
gems for different projects, as
outlined in this blog post.
Given the above, I'm confused as to why I would want to use RVM to manage Ruby versions and gems. The idea of using a bash script to install software on my system outside the package manager feels very hackish, a feeling backed up by this blog post.
Not being a Mac user I am totally guessing here, but I thought it might be that OS X is very popular in the Ruby community. If there is no system like update-alternatives for switching ruby versions on OS X, RVM might be the best solution and this idea has carried over to linux too.. like I said, this is just a guess.
So why is RVM so popular, and why should I prefer it over the regular package manager + Bundler on Debian or Ubuntu?
If you need to manage many project with diferent versions of Ruby and special Rails like me (I have 3 project to manage wich uses Rails 2.3.5, Rails 3.0.5 and Rails 3.1 rc1) do RVM is nessesary solution. As you may know Rails 2.3.x has no bundler support and uses old gems so version managing is the way to make developing easier. I hope I helped you alittle.
RVM is portable
update-alternatives works globally, RVM works in shell/script context - I suppose it is modyfying env paths. Now imagine having two apps on one server: one 1.8.7 and another 1.9.2
Usage of Ruby EE requires manual installation - with RVM it is matter of one command to install it.
I had too much problems with mixed gem dirs with 1.8.7 only or 1.9.2 only gems in Debian.
Easy backup - just copy .rvm dir.
Consistent clustering (same platform) - just share one .rvm dir.

Best way to update Ruby to the latest 1.9 version on OS X?

Does Mac OS X support ruby version 1.9.+? Is it recommended to update to 1.9 or should I wait?
The reason I ask is because I'm trying to use some plugins that only support Ruby 1.9+
Most people use RVM to install Ruby on the mac. Basically it allows you to have multiple versions of ruby installed on the same machine and to switch between them at will. You can also install gems on a project by project basis rather than installing them all globally using sudo like you probably do now.
You can install RVM by running
bash < <(curl -s https://rvm.ioinstall/rvm)
in terminal (assuming you have git installed). Full installation instructions can be found on the RVM site.
Here is a tutorial which I personally found invaluable when getting used to using RVM in my workflow at the start. It will probably help you too.
I wouldn't try to update the system Ruby, since OS X uses it for some stuff (I think). Instead, use RVM.
I won't recommend a "preferred" method, but just outline the possibilities:
Install ruby 1.9 from ports using port install ruby19 +nosuffix
Install using RVM as others suggested
Check out the stable version with svn, then
./configure --prefix=/opt/ruby --enable-shared
make && sudo make install
I prefer the third way, as it gives the most flexibility, and the latest stable version. Don't forget to add /opt/ruby/bin to path before everything else if you choose this path (no pun intended).
And as others said - don't touch the system ruby, Mac OS X depends on it.
You can install MacRuby.
It can be installed along with regular Ruby as the commands of MacRuby begins with "mac", so, irb is macirb and ruby is macruby.
Having both installed, you can choose which one use in each moment by prefixing the "mac" string or not
I'd leave the system Ruby alone. Most people would just use RVM to install 1.9, but Homebrew also has Ruby 1.9.2 available.
I'd recommend using Homebrew to install it (into /usr/local).

How to upgrade from Ruby 1.9.2p0 to ruby 1.9.2p180 without rvm?

I have searching around for upgrading ruby 1.9.2p0 to ruby 1.9.2p180 as I got some compatibility issues in my application. I searched on web and studied but am unable to do it. I know that this has already been discussed a lot, but still I'm unable to figure it out. Also I don't want to use rvm. So looking for fast responses with simple ways to upgrade ruby 1.9.2p180.
Just go to the ruby site, and download it. Extract it, cd to the extracted directory, then do as usual:
./configure
make
sudo make install
Either look for another universe that has a more recent package or install from source.

Resources