Ruby environments

From wikinotes

Describe and build environments to run ruby code.

ruby version

ruby chruby
ruby rbenv
mkdir myproject && cd myproject
echo 2.6.5 > .ruby-version   # set 'chruby' ruby version
bundle init                  # create Gemfile
bundle install --path .gems  # install gems to '.gems' (and remember for future)


ruby bundler
nix ruby

module paths

env RUBYLIB=/some/dir ruby # set $LOAD_PATH from outside ruby
p $LOAD_PATH  # all directories ruby modules will be loaded from

# list all files by $LOAD_PATH directory
$LOAD_PATH.each do |dir|
  children = [];
  children = Dir.children(dir) if Dir.exist?(dir);
  p "=" * dir.length
  p dir
  p "=" * dir.length
  children.each { |child| p child }