Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Improve hint on conflict error message #3977

Merged

Conversation

seanlinsley
Copy link
Contributor

Given this previous configuration:

gem 'rails',      '~> 4.1.11'
gem 'sass-rails', '~> 4.0.3'

When changing both gem versions:

gem 'rails',      '~> 4.2.4'
gem 'sass-rails', '~> 5.0.0'

And running bundle update rails, you see this error message:

You have requested:
  sass-rails ~> 5.0.0

The bundle currently has sass-rails locked at 4.0.3.
Try running `bundle update sass-rails`

This commit adds a hint to run bundle update rails sass-rails:

You have requested:
  sass-rails ~> 5.0.0

The bundle currently has sass-rails locked at 4.0.3.
Try running `bundle update sass-rails`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`

Given this previous configuration:
```ruby
gem 'rails',      '~> 4.1.11'
gem 'sass-rails', '~> 4.0.3'
```

When changing both gem versions:
```ruby
gem 'rails',      '~> 4.2.4'
gem 'sass-rails', '~> 5.0.0'
```

And running `bundle update rails`, you see this error message:
```
You have requested:
  sass-rails ~> 5.0.0

The bundle currently has sass-rails locked at 4.0.3.
Try running `bundle update sass-rails`
```

This commit adds a hint to run `bundle update rails sass-rails`:
```
You have requested:
  sass-rails ~> 5.0.0

The bundle currently has sass-rails locked at 4.0.3.
Try running `bundle update sass-rails`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
```
@seanlinsley
Copy link
Contributor Author

I would have provided the direct example to run the command with any/all gems currently being updated, but I wasn't sure where I could find that information

@indirect
Copy link
Member

indirect commented Sep 7, 2015

Uh... huh. So this is, I guess, very counter-intuitive, but what you actually wanted from the very beginning was to just run bundle install. That will install the versions you ask for in your Gemfile, period.

The bundle update command is for when you don't change the Gemfile. You might have put e.g. gem "rails", "~> 4.2.0". When Rails 4.2.1 comes out, you can run bundle update rails to update your lock file from 4.2.0 to 4.2.1.

Does that make sense?

@seanlinsley
Copy link
Contributor Author

bundle update is needed, because it involves changes to the lockfile. Simply changing the Gemfile as shown above and running bundle install results in this error:

You have requested:
  rails ~> 4.2.4

The bundle currently has rails locked at 4.1.11.
Try running `bundle update rails`

Hasn't that always been how Bundler works? I've always thought that bundle update was required if the lockfile needs to be changed.

I didn't specify before, but I'm using Bundler 1.10.6

@indirect
Copy link
Member

indirect commented Sep 7, 2015

😳 You're completely right. Once a gem is locked, you do need to use update to unlock it and install a different version. Sorry about that, what I said was completely wrong.

Now I'm really curious... knowing that gems will stay locked unless you pass their name to bundle update (or run it without arguments), what were you expecting to happen when you changed two gems in the Gemfile, even though they were both already locked in the lock file, and then only unlocked one at a time using bundle update? Were you expecting them to both unlock simultaneously because you changed both of their version numbers?

@segiddins
Copy link
Member

👍🏻

indirect added a commit that referenced this pull request Sep 8, 2015
@indirect indirect merged commit 9cb7734 into rubygems:master Sep 8, 2015
@seanlinsley seanlinsley deleted the update-conflict-error-message branch September 8, 2015 22:24
@seanlinsley
Copy link
Contributor Author

Were you expecting them to both unlock simultaneously because you changed both of their version numbers?

I don't know what I was expecting, but I didn't yet know that I could pass multiple gems to bundle update, so I didn't know how to get around the error while updating only those gems.

Thanks for merging this 😸 my first bundler PR!

@coilysiren coilysiren modified the milestone: Release Archive Oct 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants