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

Fix NoMethodError during bundle update --group #6157

Conversation

mattbrictson
Copy link
Contributor

What was the end-user problem that led to this PR?

#6156: NoMethodError: undefined method `version' for nil:NilClass

What was your diagnosis of the problem?

The bundler gem does not participate in the lockfile, but it can still be included in the list of dependencies that are being updated by bundle update if --group is specified.

For example, if a Gemfile contains bundler-audit (which depends on bundler) in the :development group, then updating with the option --group=development will naturally include bundler in the list of gems to evaluate for updating.

The trouble is that since bundler is excluded from the lockfile, searching the locked gems for a gemspec for bundler will return nil. This caused the following error during bundle update:

NoMethodError: undefined method `version' for nil:NilClass

What is your fix for the problem, implemented in this PR?

This PR solves this bug by skipping over gems (i.e bundler) that are not in the lockfile when comparing gem versions at the conclusion of the upgrade command.

Fixes #6156.

Why did you choose this fix out of the possible options?

I chose this fix because the bug seems to have been introduced by 618c09b. My fix takes place within the new feature that was added in that commit, so it seems safe and unlikely to have side-effects.

@ghost
Copy link

ghost commented Nov 7, 2017

Thanks for opening a pull request and helping make Bundler better! Someone from the Bundler team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use Travis CI to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of Travis CI in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #bundler channel on Slack.

For more information about contributing to the Bundler project feel free to review our CONTRIBUTING guide

CHANGELOG.md Outdated
@@ -11,6 +11,7 @@ Bugfixes:
- prioritise explicitly requested gems in dependency resolution sort order (@segiddins)
- reduce memory usage during dependency resolution ([#6114](https://github.com/bundler/bundler/issues/6114), @greysteil)
- ensure that the default bundler gem is not accidentally activated on ruby 2.5 when using local git overrides (@segiddins)
- fix `NoMethodError` when using the `--group` option with `bundle update` ([#6156](https://github.com/bundler/bundler/issues/6156), @mattbrictson)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't amend the Changelog, changes are added when we make a new release

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry! I'll remove it. I was following the instructions in Bundler's documentation for submitting pull requests:

Don't forget to add your changes into the CHANGELOG! If you're submitting documentation, note the changes under the "Documentation" heading.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattbrictson thanks for catching this! we automated the changelog since those docs were written. We'll update it. :)

The `bundler` gem does not participate in the lockfile, but it can still
be included in the list of dependencies that are being updated by
`bundle update` if `--group` is specified.

For example, if a Gemfile contains `bundler-audit` (which depends on
`bundler`) in the `:development` group, then updating with the option
`--group=development` will naturally include `bundler` in the list of
gems to evaluate for updating.

The trouble is that since `bundler` is excluded from the lockfile,
searching the locked gems for a gemspec for bundler will return `nil`.
This caused the following error during `bundle update`:

    NoMethodError: undefined method `version' for nil:NilClass

This commit solves this bug by skipping over gems (i.e `bundler`) that
are not in the lockfile when comparing gem versions at the conclusion of
the upgrade command.
@mattbrictson mattbrictson force-pushed the fix-nomethoderror-bundle-update-group branch from d07da81 to d403790 Compare November 8, 2017 15:29
@mattbrictson
Copy link
Contributor Author

Amended to remove CHANGELOG entry.

@indirect
Copy link
Member

indirect commented Nov 8, 2017

@bundlerbot r+

@bundlerbot
Copy link
Collaborator

📌 Commit d403790 has been approved by indirect

@bundlerbot
Copy link
Collaborator

⌛ Testing commit d403790 with merge 892a637...

bundlerbot added a commit that referenced this pull request Nov 8, 2017
…oup, r=indirect

Fix NoMethodError during `bundle update --group`

### What was the end-user problem that led to this PR?

#6156: NoMethodError: undefined method `version' for nil:NilClass

### What was your diagnosis of the problem?

The `bundler` gem does not participate in the lockfile, but it can still be included in the list of dependencies that are being updated by `bundle update` if `--group` is specified.

For example, if a Gemfile contains `bundler-audit` (which depends on `bundler`) in the `:development` group, then updating with the option `--group=development` will naturally include `bundler` in the list of gems to evaluate for updating.

The trouble is that since `bundler` is excluded from the lockfile, searching the locked gems for a gemspec for bundler will return `nil`. This caused the following error during `bundle update`:

    NoMethodError: undefined method `version' for nil:NilClass

### What is your fix for the problem, implemented in this PR?

This PR solves this bug by skipping over gems (i.e `bundler`) that are not in the lockfile when comparing gem versions at the conclusion of the upgrade command.

Fixes #6156.

### Why did you choose this fix out of the possible options?

I chose this fix because the bug seems to have been introduced by 618c09b. My fix takes place within the new feature that was added in that commit, so it seems safe and unlikely to have side-effects.
@bundlerbot
Copy link
Collaborator

☀️ Test successful - status-travis
Approved by: indirect
Pushing 892a637 to master...

@bundlerbot bundlerbot merged commit d403790 into rubygems:master Nov 8, 2017
@segiddins segiddins added this to the 1.16.1 milestone Nov 8, 2017
bundlerbot added a commit that referenced this pull request Nov 8, 2017
Stop requesting changelogs in PRs

We added this requirement before the changelog was automated. Now that the changelog generated by a script, it's not helpful for PRs to update the changelog anymore, so we shouldn't expect it anymore.

### What was the end-user problem that led to this PR?

We had to [ask a PR to remove a changelog entry](#6157 (comment)), even though the PR was following [the docs](https://github.com/bundler/bundler/blob/374caf6ede2cf4de7d2196aa2e2adef782bea5bd/doc/development/PULL_REQUESTS.md#changelogmd).

### What was your diagnosis of the problem?

It looks like we failed to update the docs when we automated generating the changelog.

### What is your fix for the problem, implemented in this PR?

Removing the changelog requirement from the docs hopefully means that future PRs will not include changelog entries, and we can generate future changelogs automatically.

### Why did you choose this fix out of the possible options?

I chose this fix because it seemed like the smallest change that would accomplish the goal.

/cc @mattbrictson
hsbt pushed a commit to hsbt/bundler that referenced this pull request Dec 11, 2017
…pdate-group, r=indirect

Fix NoMethodError during `bundle update --group`

### What was the end-user problem that led to this PR?

rubygems#6156: NoMethodError: undefined method `version' for nil:NilClass

### What was your diagnosis of the problem?

The `bundler` gem does not participate in the lockfile, but it can still be included in the list of dependencies that are being updated by `bundle update` if `--group` is specified.

For example, if a Gemfile contains `bundler-audit` (which depends on `bundler`) in the `:development` group, then updating with the option `--group=development` will naturally include `bundler` in the list of gems to evaluate for updating.

The trouble is that since `bundler` is excluded from the lockfile, searching the locked gems for a gemspec for bundler will return `nil`. This caused the following error during `bundle update`:

    NoMethodError: undefined method `version' for nil:NilClass

### What is your fix for the problem, implemented in this PR?

This PR solves this bug by skipping over gems (i.e `bundler`) that are not in the lockfile when comparing gem versions at the conclusion of the upgrade command.

Fixes rubygems#6156.

### Why did you choose this fix out of the possible options?

I chose this fix because the bug seems to have been introduced by 618c09b. My fix takes place within the new feature that was added in that commit, so it seems safe and unlikely to have side-effects.
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.

NoMethodError: undefined method `version' for nil:NilClass
5 participants