pjbaur
4/22/2019 - 9:06 AM

Ruby development environment with rbenv and bundler

Ruby development environment with rbenv and bundler

Ruby

Rbenv

Used to manage ruby environment, since it is more beneficial and clean to use non-system one.

Install rbenv and ruby-build

brew install rbenv ruby-build rbenv-vars

Add to .zshrc (or .bashrc) the following:

export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

Restart shell session. (close shell tab or window and open again).

Ruby

Install Ruby interpreter

rbenv install 2.2.3
rbenv rehash

Use newely installed Ruby 2.2.3 by default

rbenv global 2.3.3

Install bundler system-wide

gem install bundler

Bundler

By default move executables installed by bundler to .bin dir

bundle config bin .bin --global

By default install bundler dependencies to vendor/bundle

bundle config path vendor/bundle --global

Add .bin to PATH, so that it would be possible to run commands without bundle exec

export PATH=".bin:$PATH"

To make gem command aware of application specific dependencies, create /usr/local/var/rbenv/vars with the following contents

GEM_PATH=vendor/bundle

Intellij IDEA

Make it aware of rbenv

ln -s /usr/local/var/rbenv ~/.rbenv