You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
Essentially if you have a Gemfile with multiple gems coming from the same git source but with different subfolders then bundle install will error out because it cannot find the dependency. The most simple example I could come up with was:
Running bundle install with this gemfile will result in the following error:
Fetching git@github.com:ajorgensen/bundler-poc.git
Fetching gem metadata from https://rubygems.org/
Could not find gem 'base_gem' in git@github.com:ajorgensen/bundler-poc.git (at master@002e6fd).
The source does not contain any versions of 'base_gem'
This is surprising because I would expect that this should work correctly. The workaround I found was to do something like this:
By simply always including all of the gemspecs I can get bundle install to work correctly.
I did a bit of digging and my hypothesis is that the source is getting added for each of the different gems but the options are getting overwritten because the source itself is the same for both gems. So in the broken case, the source would get added first with the one glob option and then it is added a second time and overwrites the existing glob option. I believe this is happening somewhere around here: https://github.com/bundler/bundler/blob/master/lib/bundler/source_list.rb#L125-L128
I will admit I have very little knowledge of how bundler works but my naive thought would be that sources should be treated separately if they have different options or add in some special logic to merge the two sources so the options like glob aren't overwritten but merged.
I will continue to dig deeper into this and see if I can find an elegant way to fix this behavior but I thought I would put up an issue to see if someone who knows more has a more clever idea.
The text was updated successfully, but these errors were encountered:
@ajorgensen This is being fixed in #7419. Can you give that a try and see if it works for you?
Also, note that the default behavior of bundler is to consider all gemspecs in the git source for resolving (as you noticed). I think this is because normally inside monorepos gems are dependent on each other, so this is what you usually want.
I can see though how there could be cases were you don't want the default behavior and prefer to be explicit about gemspecs for each gem in the git source. Specially since, even if very niche, the git source already has this :glob option as a feature, so this is arguably a bug.
I've created a POC project for this behavior (https://github.com/ajorgensen/bundler-poc) but I will also summarize the behavior here.
Essentially if you have a
Gemfile
with multiple gems coming from the same git source but with different subfolders thenbundle install
will error out because it cannot find the dependency. The most simple example I could come up with was:Running
bundle install
with this gemfile will result in the following error:This is surprising because I would expect that this should work correctly. The workaround I found was to do something like this:
By simply always including all of the gemspecs I can get
bundle install
to work correctly.I did a bit of digging and my hypothesis is that the source is getting added for each of the different gems but the options are getting overwritten because the source itself is the same for both gems. So in the broken case, the source would get added first with the one
glob
option and then it is added a second time and overwrites the existingglob
option. I believe this is happening somewhere around here: https://github.com/bundler/bundler/blob/master/lib/bundler/source_list.rb#L125-L128I will admit I have very little knowledge of how bundler works but my naive thought would be that sources should be treated separately if they have different options or add in some special logic to merge the two sources so the options like
glob
aren't overwritten but merged.I will continue to dig deeper into this and see if I can find an elegant way to fix this behavior but I thought I would put up an issue to see if someone who knows more has a more clever idea.
The text was updated successfully, but these errors were encountered: