0
0
Rubyprogramming~20 mins

Bundler for dependency resolution in Ruby - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bundler Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Bundler command?
You run bundle list in a Ruby project with a Gemfile containing gem 'rack', '~> 2.2'. What will Bundler display?
Ruby
bundle list
A
Gems included by the bundle:
  * rack (2.2.3)
BCould not find gem 'rack (~> 2.2)' in any of the sources
CFetching gem metadata from https://rubygems.org/...
DBundler version 2.3.0
Attempts:
2 left
💡 Hint
Think about what bundle list shows after gems are installed.
🧠 Conceptual
intermediate
1:30remaining
What does the Gemfile.lock file do?
In a Ruby project using Bundler, what is the main purpose of the Gemfile.lock file?
AIt contains the source code of all gems used in the project.
BIt records the exact versions of gems installed to ensure consistent installs.
CIt specifies the Ruby version required by the project.
DIt lists all available gems on RubyGems.org.
Attempts:
2 left
💡 Hint
Think about how Bundler ensures everyone uses the same gem versions.
🔧 Debug
advanced
2:30remaining
Why does this Bundler install fail?
You run bundle install but get this error:
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 6.1.0)

Another dependency requires rails (~> 7.0)

What is the cause?
AThe network connection to RubyGems.org is down.
BThe Gemfile.lock is missing, so Bundler cannot install gems.
CThe Gemfile requests rails 6.1.x but another dependency requires rails 7.0 or higher.
DThe Ruby version is incompatible with rails 6.1.
Attempts:
2 left
💡 Hint
Look at the version requirements in the error message.
📝 Syntax
advanced
2:00remaining
Which Gemfile syntax is correct for specifying a source and a gem with a version constraint?
Choose the correct Gemfile syntax to specify RubyGems.org as the source and include the gem 'nokogiri' version '~> 1.12'.
A
source = 'https://rubygems.org'
gem 'nokogiri', version: '~> 1.12'
B
source: 'https://rubygems.org'
gem 'nokogiri' version '~> 1.12'
C
source('https://rubygems.org')
gem('nokogiri', '~> 1.12')
D
source 'https://rubygems.org'
gem 'nokogiri', '~> 1.12'
Attempts:
2 left
💡 Hint
Gemfile uses Ruby DSL syntax, not hash or method calls.
🚀 Application
expert
3:00remaining
How to update a single gem without changing others?
You want to update only the 'puma' gem to the latest compatible version without updating other gems in your bundle. Which Bundler command should you use?
Abundle update puma
Bbundle upgrade puma
Cbundle install --update puma
Dbundle install --only puma
Attempts:
2 left
💡 Hint
Check Bundler's command to update specific gems.