Bird
0
0

You wrote gem 'rails', '~> 5.2.0' but bundler installs version 6.0.0. What is the likely cause?

medium📝 Debug Q6 of 15
Ruby - Gems and Bundler
You wrote gem 'rails', '~> 5.2.0' but bundler installs version 6.0.0. What is the likely cause?
AAnother gem requires rails 6.0.0 causing conflict resolution
BBundler ignores version constraints by default
CThe ~> operator was misused; it allows major version updates
DThe Gemfile syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Understand the ~> 5.2.0 constraint

    This constraint allows versions >= 5.2.0 and < 5.3.0, so 6.0.0 should not be installed.
  2. Step 2: Consider bundler dependency resolution

    If bundler installs 6.0.0, it is likely due to another gem requiring rails 6.0.0, causing bundler to resolve to that version despite the constraint.
  3. Final Answer:

    Another gem requires rails 6.0.0 causing conflict resolution -> Option A
  4. Quick Check:

    Dependency conflicts can override constraints = Another gem requires rails 6.0.0 causing conflict resolution [OK]
Quick Trick: Check other gems' requirements when unexpected versions install [OK]
Common Mistakes:
  • Assuming ~> allows major updates
  • Thinking bundler ignores constraints
  • Blaming syntax without checking dependencies

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes