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

Bundler displays a duplicate gem entries warning even if gems only appear once per group #7302

Merged
1 commit merged into from
Aug 18, 2019

Conversation

davidstosik
Copy link
Contributor

@davidstosik davidstosik commented Aug 15, 2019

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

I have a Gemfile where some gems appear in two distinct groups. When I run Bundle, the following warning is displayed:

Your Gemfile lists the gem #{gem} more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once (per group).
While it's not a problem now, it could cause errors if you change the version of one of them later.

Example Gemfile:

source "https://rubygems.org"

group :production do
end

group :development do
  gem "rake"
end

group :ci, optional: true do
  gem "rake"
end

What was your diagnosis of the problem?

I think the message is misleading, because it shows even if all gems are specified only once per group.

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

I removed the (per group) mention from the warning message in order to prevent confusion.

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

I chose this fix because it was the simplest way to bring your attention to the problem.

If Bundler's real intent is to allow the same gem to appear in multiple groups, as long as it does not appear more than once per group, then my suggestion is wrong, and instead, the logic around the warning message needs to be fixed.

@welcome
Copy link

welcome bot commented Aug 15, 2019

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

@davidstosik
Copy link
Contributor Author

davidstosik commented Aug 15, 2019

Note that while Bundler raises this warning, I can fix my Gemfile this way:

source "https://rubygems.org"

group :production do
end

group :development, :ci do
  gem "rake"
end

group :ci, optional: true do
end

(In reality I have more gems, some only for CI, some only for development.)

@deivid-rodriguez
Copy link
Member

Yeah, my guess is that this is to not give the false impression that bundler supports separate resolutions per group, and that you can specify separate (possibly incompatible) dependencies for the same gem in different groups.

So, to me, this PR is good 👍.

@hsbt
Copy link
Member

hsbt commented Aug 17, 2019

@bundlerbot r+

ghost pushed a commit that referenced this pull request Aug 17, 2019
7302: Bundler displays a duplicate gem entries warning even if gems only appear once per group r=hsbt a=davidstosik

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

I have a Gemfile where some gems appear in two distinct groups. When I run Bundle, the following warning is displayed:

> Your Gemfile lists the gem #{gem} more than once.
> You should probably keep only one of them.
> Remove any duplicate entries and specify the gem **only once (per group)**.
> While it's not a problem now, it could cause errors if you change the version of one of them later.                                                           

Example Gemfile:
```rb
source "https://rubygems.org"

group :production do
end

group :development do
  gem "rake"
end

group :ci, optional: true do
  gem "rake"
end
```

### What was your diagnosis of the problem?

I think the message is misleading, because it shows even if all gems are specified **only once per group**.

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

I removed the _(per group)_ mention from the warning message in order to prevent confusion.

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

I chose this fix because it was the simplest way to bring your attention to the problem.

If Bundler's real intent is to allow the same gem to appear in multiple groups, as long as it does not appear more than once per group, then my suggestion is wrong, and instead, the logic around the warning message needs to be fixed.

Co-authored-by: David Stosik <[email protected]>
@ghost
Copy link

ghost commented Aug 18, 2019

Build succeeded

@ghost ghost merged commit d18a831 into rubygems:master Aug 18, 2019
@davidstosik davidstosik deleted the gem-only-once-per-group branch August 19, 2019 08:34
This pull request was closed.
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.

3 participants