0
0
Rubyprogramming~10 mins

Ruby version management (rbenv, rvm) - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Ruby version management (rbenv, rvm)
Install rbenv or rvm
Initialize environment
List available Ruby versions
Install chosen Ruby version
Set global or local Ruby version
Use Ruby version in shell
Run Ruby programs with selected version
This flow shows how you install and use rbenv or rvm to manage Ruby versions step-by-step.
Execution Sample
Ruby
rbenv install 3.1.2
rbenv global 3.1.2
ruby -v
This code installs Ruby 3.1.2, sets it as the global version, then shows the Ruby version in use.
Execution Table
StepCommandActionResult/Output
1rbenv install 3.1.2Downloads and installs Ruby 3.1.2Ruby 3.1.2 installed
2rbenv global 3.1.2Sets Ruby 3.1.2 as global versionGlobal Ruby version set to 3.1.2
3ruby -vChecks current Ruby versionruby 3.1.2p0 (output depends on exact patch)
4exitEnd of commandsExecution stops
💡 All commands executed; Ruby version 3.1.2 is active globally
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
Ruby version installednone3.1.2 installed3.1.2 installed3.1.2 installed3.1.2 installed
Global Ruby versiondefault system Rubydefault system Ruby3.1.23.1.23.1.2
Current Ruby version (ruby -v)default system Rubydefault system Ruby3.1.23.1.23.1.2
Key Moments - 3 Insights
Why does 'ruby -v' show the system Ruby version before setting global version?
Before running 'rbenv global 3.1.2', the shell uses the default system Ruby. The execution_table row 3 shows the version after setting global version.
What happens if you install a Ruby version but don't set it as global or local?
The installed Ruby version is available but not used by default. The shell continues using the previous Ruby version until you set it, as shown between steps 1 and 2.
How does rbenv or rvm know which Ruby version to use?
They modify environment variables and shims so that when you run 'ruby', the selected version runs. This is reflected in the change of 'Global Ruby version' in variable_tracker after step 2.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output of 'ruby -v' at step 3?
Aruby 3.1.2p0
Bruby 2.7.0
CCommand not found
Druby 3.0.0
💡 Hint
Check the 'Result/Output' column for step 3 in execution_table.
At which step is the global Ruby version set to 3.1.2?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the 'Action' column in execution_table to find when global version changes.
If you skip 'rbenv global 3.1.2', what Ruby version will 'ruby -v' show at step 3?
A3.1.2
BSystem default Ruby
CNo Ruby version
DError message
💡 Hint
Refer to variable_tracker for 'Global Ruby version' before step 2.
Concept Snapshot
Ruby version management lets you install and switch Ruby versions easily.
Use rbenv or rvm to install versions.
Set global or local version to choose which Ruby runs.
Check with 'ruby -v' to confirm active version.
This helps run different projects with different Ruby versions.
Full Transcript
This visual trace shows how Ruby version managers like rbenv or rvm work step-by-step. First, you install a Ruby version using a command like 'rbenv install 3.1.2'. Then you set that version as the global default with 'rbenv global 3.1.2'. Finally, running 'ruby -v' shows the active Ruby version, confirming the switch. Variables track the installed Ruby versions and which one is active globally. Key moments clarify why the Ruby version changes only after setting global version and how the environment is configured. The quiz tests understanding of these steps and outputs. This helps beginners see how Ruby version management commands affect the environment and Ruby version used.