How to update system Ruby to 1.9.2 on Mac? - ruby

I saw an answer saying I should use RVM. But I don't know how even after:
$ rvm system
$ rvm current
system
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

The title of the question, "How to update system Ruby to 1.9.2 on Mac" makes me wonder if you are trying to upgrade Apple's installation of Ruby 1.8.7 to 1.9.2. If that is true, STOP and do NOT try that. The Ruby installed by Apple is for their use, and apps installed by Apple use it.
find /usr -name '*.rb'
will list the reasons why.
RVM and other apps allow you to install Ruby safely, so unless you have very good knowledge of how Unix and the Mac work I strongly recommend you stick to them.
A very common problem we see is that the installation wasn't completed. Read the "Installation" section in the RVM installation page to double-check you've completed everything.
To install Ruby 1.9.2 do:
rvm notes
and read and install the needed dependencies. Then do:
rvm install 1.9.2
rvm use 1.9.2 --default
will tell RVM to always use 1.9.2 as a default. You can switch to the system version installed by Apple using:
rvm use system
and switch back using
rvm default

If you don't want an RVM-based solution:
Download and install Apple's Xcode developer tools so you get GCC et al, the ability to build your own software. (This is 4.25GB, but you only need to download it once.)
Download and extract the Ruby Source Code. (10.6MB)
Open a Terminal window and change into the directory of the source code.
Run the command ./configure && make; get a cup of tea while you wait
Run the command sudo make install to install this Ruby; you'll need to supply your administrator password
Modify your PATH environment variable to put /usr/local/bin in front of /usr/bin (so that your new Ruby is found before the system Ruby). You can do this by creating or editing a .profile file in your home directory to have the line:
export PATH="/usr/local/bin::$PATH"
If you're running TextMate, you'll also want to go to TextMate ▸ Preferences ▸ Advanced ▸ Shell Variables
and add or edit a PATH variable like this:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
After this, rvm use system will use your 1.9.2p180 (the current version as of this post) install.

I'm assuming you're not sure how to install a new version of ruby with RVM - try:
rvm install 1.9.2
To then make it the default version to use:
rvm use 1.9.2 --default

Consider also: "for OS X try using RailsInstaller for OS X or try the official RVM GUI JewelryBox" -- Quoted from from the 4rd or 5th screen the RVM install page found here http://rvm.io/rvm/install

Whatever you do do not touch or mess with the system default Ruby that ships with your Mac I did that to see what would and my system was out of whack. If you would like to use a different version of Ruby use rvm.

Related

Can I upgrade to the current version of Ruby (2.2.3) on OS X v10.6.8?

I'm looking at "Install Ruby on Rails · Mac OS X Yosemite", and in the instructions it says to update your OS which I don't really want to do because my computer is getting old.
I also found "How to update Ruby to 1.9.x on Mac?". As far as I can tell, I don't have RVM and I'm afraid of yet another install, in case my system requirements still aren't good enough.
Ultimately, I'm trying to update Jekyll, but I need to update my system a little bit first. I need Ruby 1.9.3 or later. Will "How to update Ruby to 1.9.x on Mac?" work? I'm running Ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0]'.
EDIT: I did end up getting RVM installed. For those who find this page in the future, I ran into these issues/help pages:
How to resolve "gpg: command not found" error during RVM installation?
OS X Mavericks install rvm WARNING * WARNING: You have '~/.profile' file...
RVM installation missing $PATH * WARNING: Above files containsPATH=with no$PATHinside
I suggest that you use RVM to install Ruby.
curl -sSL https://get.rvm.io | bash -s stable --ruby
You need to restart the terminal in order to run rvm:
rvm install 2.2
rvm use 2.2 --default
This is what worked for me
\curl -sSL https://get.rvm.io | bash -s stable --ruby
For the most up-to-date info on how to do this, check this documentation.
You do not need the latest version of OSX to run an updated version of Ruby. Whether or not you need something more current than 10.6.8 to run 2.2.3 I cannot tell. But 1.9.3 should build just fine and 2.2.3 likely will as well.
Using rvm (or rbenv, or ruby-build, or whatever) is certainly an option if you are simply doing development. Then you can have multiple ruby versions at your command without having to disturb the system ruby. Be aware these are not a panacea. Each has its own complexities and egocentricities. Go to the project websites and read the documentation carefully or you can easily get betrayed by your assumptions about how things 'should' work.
All of ruby version managers should install on any version of OSX that supports the build tools required by the Ruby that you want to host. However, be aware you will need installed the OSX xcode application for your system (available free from the Apple App Store but you need an account) and you will need the optional command line tools for xcode as well (also from the App Store).
If you want to update the system ruby then take a look at either the homebrew or macports projects. These provide up to date versions of many, many linux projects for OSX, including Ruby (and git). You will need to meet the same xcode requirements. A build is a build wherever the binaries end up.
The system from which I am writing this answer once ran Snow Leopard and I had at least Ruby 1.9 dot something installed on it via Ports. I am currently paused at 10.9.5 and am running:
ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin13]
Without any problems.
In case anyone bumps into the same error I did: “Requirements installation failed with status: 1.”, you need to install homebrew.
Use this:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

installing RubyGem on CentOs 5

My ultimate goal is to install Sass.
To do this I need to install RubyGems
To do this I need to install Ruby.
I installed Ruby with yum.
I then tried to install gem with yum yum install rubygem
The response is "nothing to do" and yet when I write gem install sass I get:
gem: command not found
I decided to try to install rubygems 2.2.2 manually. After downloading it, I tried to run ruby setup.rb and in response I get:
Rubygems now requires Ruby 1.8.7 or later
But yum does not seem to be able to install anything later than 1.8.5.
So now I'm trying to do this manually.
I downloaded Ruby 1.9.2 to my home directory and followed these instructions: http://howboring.com/post/1226760251/centos-5-and-rails-3-and-ruby-1-9-2
This seems to work, but the problem is ruby1.9.2 is installed in my home directory (i.e. ~/ruby1.9.3 not system wide.
Thus in the directory where I installed ruby 1.9.2 ruby -v still gives 1.8.5 but ./ruby -v returns 1.9.2. And which ruby returns /usr/bin/ruby (I suppose I could replace this with a symlink that points to ~/ruby1.9.2/ruby but this doesn't seem like a "best practice")
So my main question is where should install ruby 1.9.2 with Root Permissions so that 1.8.5 is replaced with 1.9.2 system wide.
My corollary question is: is there any easier way to do this? (perhaps install sass without install rubygems??)
I then tried to install gem with yum yum install rubygem
You have a typo in the package name, it is actually named rubygems.
Can i suggest Wayne Seguins excellent rvm (ruby version manager). As the home page states:
"RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems".
Site has comprehensive installation instructions. I've posted a truncated Set of instructions for installing on POSIX systems below, but please refer to the projects' home page as:
"we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods."
Install RVM (development version):
\curl -sSL https://get.rvm.io | bash
Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:
user$ source ~/.rvm/scripts/rvm
test the installation was successful:
user$ type rvm | head -n 1
this should output "rvm is a function"
List all known rubies:
rvm list known //this will output a large list of rubies shortened here
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1[.1]
[ruby-]2.1-head
ruby-head
...
install the version you want:
rvm install 1.9.2
You can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:
rvm use 2.1 --default
You can also temporarily use another version of your ruby versions
rvm list known //lists system available rubies
Choose to use another ruby
rvm use 1.9.3
RVM is a great tool, well documented, and actively developed, it handles a wider scope of functionality than i can list here, and it's a tool I use everyday.
You can use rbenv to install ruby and rubygems that you need
https://gist.github.com/jpfuentes2/2002954

why my ruby version is still an old version on ubuntu after I installed ruby1.9.2?

I am newbie to ubuntu and ROR. After installed latest ruby1.9.2 with apt-get, type "ruby -v" it still shows up old version ruby1.8.7. I tried to reinstall with rvm, nothing changed.
As mentioned in similar question, I tried to remove ruby, and reinstall ruby1.9.1-full... still the same thing...
What else I can do about this?
ubuntu uses a something called alternatives for chosing between two version of similar executable. Running
sudo update-alternatives --config ruby
and chosing the ruby you want should do the trick
I'm using RVM myself, but if I remember correctly, ruby1.8 and ruby1.9 can be installed side by side on Ubuntu. ruby is just a symbolic link which points to version 1.8 by default - which should be called ruby1.8 and stored in the same directory. 1.9 will be called ruby1.9.
So just find where ruby symbolic link is (whereis ruby) and change it so it points to ruby1.9.
sudo rm /path/ruby
sudo ln -s /path/ruby1.9 /path/ruby
Sounds like you are using rvm, but still referencing system ruby. To switch, you have to tell rvm what version to use.
rvm use 1.9.2
This will switch your current environment only. So ruby -v in your current shell will use the right version. (you should probably go with 1.9.3, FWIW) If you want to always use that ruby be default, you type:
rvm use 1.9.2 --default
If you want to switch back to system ruby, you can use:
rvm use system
I think it is because the package of Ruby version at apt-get repository is an old version.
I suggest use rbenv to install the latest version.
Here is a great tutorial using rbenv to install the latest Ruby version from Digital Ocean:
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04
sudo apt-get install ruby1.9
should do the trick.
You can find what libraries are available to install by
apt-cache search <your search term>
So I just did apt-cache search ruby | grep 9 to find it.
You'll probably need to invoke the new Ruby as ruby1.9, because Ubuntu will probably default to 1.8 if you just type ruby.

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