Skip to content

Instantly share code, notes, and snippets.

@tommydunn
Created February 25, 2019 15:28
Show Gist options
  • Save tommydunn/e81c3533a249880c6beb3b46c7852c88 to your computer and use it in GitHub Desktop.
Save tommydunn/e81c3533a249880c6beb3b46c7852c88 to your computer and use it in GitHub Desktop.
title category layout updated weight description intro
rbenv
Ruby
2017/sheet
2017-10-11
-1
A one-page guide to rbenv Ruby version manager, with usage examples and more.
[rbenv](https://github.com/rbenv/rbenv) lets you manage installations of multiple Ruby versions.

Installation

Install rbenv and ruby-build

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Add to ~/.bash_profile

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Verify installation

type rbenv   # → "rbenv is a function"

These are generic instructions; there may be rbenv packages available for your OS.

See: Installation

Managing versions

Command Description
rbenv install -l List all available versions
--- ---
rbenv install 2.2.1 Install Ruby 2.2.1
rbenv uninstall 2.2.1 Uninstall Ruby 2.2.1
--- ---
rbenv versions See installed versions
rbenv version See current version
--- ---
rbenv which <NAME> Display path to executable
rbenv rehash Re-write binstubs

Using versions

{: .-three-column}

Locally

Command Description
rbenv local 2.2.2 Use Ruby 2.2.2 in project
rbenv local --unset Undo above

Application-specific version numbers are stored in .ruby-version.

Globally

Command Description
rbenv global 2.2.2 Use Ruby 2.2.2 globally
rbenv global --unset Undo above

Global version numbers are stored in ~/.rbenv/version.

Shell

Command Description
rbenv shell 2.2.2 Use Ruby 2.2.2 in shell
rbenv shell --unset Undo above

Shell-local version numbers are stored as environment variables.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment