Ruby environments: Difference between revisions
From wikinotes
No edit summary |
|||
Line 3: | Line 3: | ||
= ruby version = | = ruby version = | ||
<blockquote> | <blockquote> | ||
{| | {| | ||
|- | |- | ||
| [[ruby chruby]] | | [[ruby chruby]] | ||
Line 28: | Line 28: | ||
</blockquote><!-- requirements --> | </blockquote><!-- requirements --> | ||
= module paths = | |||
<blockquote> | |||
<syntaxhighlight lang="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 } | |||
end | |||
</syntaxhighlight> | |||
</blockquote><!-- module loading --> |
Revision as of 23:44, 5 September 2021
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)
environments
ruby bundler nix ruby
module paths
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 } end