Understanding How Rbenv, RubyGems And Bundler Work Together
Rbenv, RubyGems, and Bundler work together to give us a lot of control over our code's environment. If you know how they work, you'll be better prepar
rbenv
rbenv helps in managing multiple versions of ruby programming language on a system similar to Unix-like. Your work on different projects or may be using different software that uses different versions of ruby on the same system. For that, rbenv is used to switch the ruby version so that your program runs on the correct version of ruby.
How it works:
rbenv adds itself to PATH environment variable so that any shell command, ruby related, goes through it. rbenv creates a shim file corresponding to ruby command
#!/usr/bin/env bash
set -e
[ -n "$RBENV_DEBUG" ] && set -x
program="${0##*/}"
if [ "$program" = "ruby" ]; then
for arg; do
case "$arg" in
-e* | -- ) break ;;
*/* )
if [ -f "$arg" ]; then
export RBENV_DIR="${arg%/*}"
break
fi
;;
esac
done
fi
export RBENV_ROOT="/Users/mukeshyadav/.rbenv"
exec "/opt/homebrew/bin/rbenv" exec "$program" "$@"
https://www.honeybadger.io/blog/rbenv-rubygems-bundler-path/#authorDetails
https://www.justinweiss.com/articles/how-does-rails-handle-gems/
https://www.semicolonandsons.com/code_diary/unix/understand-shims