Ruby tips - mhulse/mhulse.github.io GitHub Wiki
Below are notes from the perspective of a Ruby noobie; I can't guarantee anything below will work for you and/or your system.
TL;DR
Assuming everything Ruby is installed:
# Update rvm:
$ rvm get stable
# Update rvm Ruby:
$ rvm install ruby --latest && rvm use current
# Upgrade RubyGems:
$ gem update --system
# Update rvm gems:
$ gem update
Before doing anything, make sure XCODE is installed (download from App Store).
Next, run:
$ xcode-select --install
… this installs the XCODE "command line developer tools".
Check ruby version:
$ ruby -v
On OS X, use Ruby Version Manager (RVM) to manage ruby gems.
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.
Installation instructions can be found on it's site, but here's a quick glimpse:
$ \curl -L https://get.rvm.io | bash -s stable --ignore-dotfiles
# --ignore-dotfiles = don't add anything to '*rc' / '*profile'.
# If you also need a fresh version of Ruby seperate from the
# system version you can append --ruby
# on to the end of this command.
Added the below to my .bash_profile
:
# Add RVM to PATH for scripting:
export PATH=${PATH}:$HOME/.rvm/bin
if [ -s $HOME/.rvm/scripts/rvm ](/mhulse/mhulse.github.io/wiki/--s-$HOME/.rvm/scripts/rvm-); then
source $HOME/.rvm/scripts/rvm;
fi
Upgrade RVM:
$ rvm get stable
If you want the latest version of RVM (may not be stable):
$ rvm get master
Test if everything is working:
type rvm | head -1
rvm is a function # This is what you want to see.
Install a fresh version of Ruby if RVM is installed but it uses your system Ruby
$ rvm install 2.1.2 #Insert the most recent version of Ruby (https://www.ruby-lang.org/en/downloads/)
Update to latest version of Ruby:
$ rvm install current && rvm use current
... this could also work:
$ # rvm upgrade 2.0.0
$ rvm upgrade 2 # Gets latest v2.
# Choose 'Y' for all the questions.
# If you wish to update your gems to the latest versions, you can do:
$ rvm all do gem update
# At some point after upgrading, you might need to do:
$ rvm alias create default ruby-2.1.1
- Docs: Setting the default Ruby
# TL;DR:
$ rvm --default use 2.1.1
Check which version of Ruby you have installed:
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.1.0]
$ rvm all do ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
Upgrade RubyGems:
$ gem update --system
Update gems:
gem update
Brew:
$ brew update
$ brew doctor
Other useful commands:
$ which ruby
$ rvm list
$ rvm all do gem list
If you ever see an error message like:
Error fetching https://rubygems.org/:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz)
This should help (you'll need to enter your password at prompt):
$ rvm osx-ssl-certs update all
Now that rvm
has been installed, you can install gem
s like normal:
$ gem install rails #, etc ...
Note: Don't forget to source your .bashrc
or restart terminal after upgrading.