From 942ccf6e0f0608f1e4460a2896fd2bcdce5bbaa3 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Wed, 11 Oct 2017 09:01:01 +0800 Subject: [PATCH] rbenv: new cheatsheet --- rbenv.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 rbenv.md diff --git a/rbenv.md b/rbenv.md new file mode 100644 index 000000000..8dd0ce902 --- /dev/null +++ b/rbenv.md @@ -0,0 +1,80 @@ +--- +title: rbenv +category: Ruby +layout: 2017/sheet +updated: 2017-10-11 +description: | + A one-page guide to rbenv Ruby version manager, with usage examples and more. +intro: | + [rbenv](https://github.com/rbenv/rbenv) lets you manage installations of multiple Ruby versions. +--- + +### Installation + +#### Install rbenv and ruby-build + +```bash +git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +``` + +#### Install rbenv and ruby-build + +```bash +echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile +echo 'eval "$(rbenv init -)"' >> ~/.bash_profile +``` + +#### Verify installation + +```bash +type rbenv # → "rbenv is a function" +``` + +These are generic instructions; there may be rbenv packages available for your OS. + +See: [Installation](https://github.com/rbenv/rbenv#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 ` | Display path to executable | +| `rbenv rehash` | Re-write binstubs | + +## Using versions +{: .-three-column} + +### Locally + +| `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 + +| `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 + +| `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 + +- [rbenv project page](https://github.com/rbenv/rbenv) _(github.com)_ +- [rbenv ubuntu server cheatsheet](https://gist.github.com/rahul286/7160839f4425a3b7e718) _(gist.github.com)_