rbenv: new cheatsheet

This commit is contained in:
Rico Sta. Cruz 2017-10-11 09:01:01 +08:00
parent eb423cabc5
commit 942ccf6e0f
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 80 additions and 0 deletions

80
rbenv.md Normal file
View File

@ -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 <NAME>` | 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)_