0
0
Rubyprogramming~20 mins

Ruby version management (rbenv, rvm) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Ruby Version Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this rbenv command?
You run the command rbenv versions after installing Ruby 3.1.2 and 2.7.6. What output will you see?
Ruby
$ rbenv versions
  system
* 3.1.2 (set by /home/user/.rbenv/version)
  2.7.6
A
  system
* 3.1.2 (set by /home/user/.rbenv/version)
  2.7.6
B
* 3.1.2
  2.7.6
  system
C
3.1.2
2.7.6
system
DNo versions installed
Attempts:
2 left
💡 Hint
The asterisk (*) marks the currently active Ruby version.
Predict Output
intermediate
1:30remaining
What happens when you run rvm use 2.6.5 if Ruby 2.6.5 is not installed?
You run rvm use 2.6.5 but Ruby 2.6.5 is not installed on your system. What will be the result?
Ruby
rvm use 2.6.5
ARVM will uninstall all Ruby versions.
BRVM will automatically download and install Ruby 2.6.5, then switch to it.
CRVM will switch to the system Ruby version instead.
DRVM will show an error: 'Unknown ruby interpreter or version: 2.6.5'.
Attempts:
2 left
💡 Hint
The plain `rvm use` command requires the version to be installed first; use `rvm install` separately.
🔧 Debug
advanced
2:00remaining
Why does ruby -v show a different version than rbenv version?
You set Ruby 3.0.0 as global with rbenv global 3.0.0, but running ruby -v shows Ruby 2.7.0. What is the most likely cause?
AYour shell environment does not have <code>rbenv</code> initialized in PATH.
BYou forgot to run <code>rbenv rehash</code> after installing Ruby 3.0.0.
CRuby 3.0.0 is not installed at all.
DYou need to uninstall Ruby 2.7.0 manually.
Attempts:
2 left
💡 Hint
Check if rbenv commands are recognized and PATH is set correctly.
📝 Syntax
advanced
1:30remaining
Which command correctly sets a local Ruby version with rbenv?
You want to set Ruby 3.2.0 only for the current project directory. Which command is correct?
Arbenv use 3.2.0
Brbenv global 3.2.0
Crbenv local 3.2.0
Drbenv set 3.2.0
Attempts:
2 left
💡 Hint
Local version affects only the current directory and subdirectories.
🚀 Application
expert
2:30remaining
How to ensure a Ruby script uses a specific Ruby version with rvm in a CI pipeline?
You want your CI pipeline to run a Ruby script using Ruby 2.7.4 managed by RVM, without affecting other jobs. Which is the best approach?
AInstall Ruby 2.7.4 globally on the CI machine and run the script directly.
BAdd <code>rvm use 2.7.4 --install --binary --fuzzy</code> before running the script.
CUse <code>rbenv local 2.7.4</code> in the CI script before running Ruby.
DSet the environment variable <code>RUBY_VERSION=2.7.4</code> and run the script.
Attempts:
2 left
💡 Hint
RVM can install and switch Ruby versions on the fly in scripts.