Ruby rbenv

From wikinotes

Isolated environment for ruby package versions, similar to python virtualenv.
Successor to ruby rvm.
Consider using ruby chruby instead.

Documentation

Docs
github https://github.com/rbenv/rbenv
Tutorials
rbenv tutorial https://www.develves.net/blogs/asd/2016-03-17-using-virtual-environments-ruby-1

Locations

~/.rbenv shims (executables && versions) are loaded from here

Install

# macos
sudo port install rbenv
sudo port install ruby-build
brew install rbenv-gemset

# linux


To automatically load your configuration, you'll need to add an entry to your .{shell}rc.

# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init -)"

Usage

# =============
# vanilla usage
# =============
# =====================
# plugin-enhanced usage
# =====================
rbenv install 2.7.0  # installs ruby 2.7.0

cd ~/yourproject
rbenv init
rbenv local 2.7.0    # writes `$(pwd)/.ruby-version`  (see `rbenv versions` )
rbenv gemset init    # writes `$(pwd)/.rbenv-gemsets`
bundle init          # writes `Gemfile`

Plugins

ruby ruby-build manage project ruby versions
ruby rbenv-gemset gems installed to project subdir, rather than into ruby install