-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Git reference inside a source block changes .lock file unexpectedly #3974
Comments
I have tested and confirmed the behaviour illustrated above. From my understanding the source block allows for gems to be retrieved from a specific source, in this case https://rails-assets.org. If the above is the case then it would seem appropriate to declare gems that will be retrieved from that source alone within the source block. However, you have a gem being declared from another source in a source block. Is there a particular reason for this? I think this would solve your issue.
None the less whatever your reason I guess what should happen is that the gems should be retreived from the reals-assets.org source until it meets the |
@rgb-one I agree it is a very weird case, but I think my last paragraph is the best example I can give. Normally a gem will come from the source, but for some development testing I might want to reference it to the a git branch rather than it come from the source. It would be nice to just be able to add the git source without having to move the gem. Your case does solve the issue, just wanted to bring up some expected behavior even if it is for an odd use case. |
Ah it seem I did some selective reading. I reread the last part of the OP and I understand your use case now. Maybe the desired behaviour could be achieved using groups. So if group is |
No, this is very clearly a bug. Thanks for reporting it, @craig-day! |
What actually happens is that any gem that's defined inside a Hopefully, #3978 fixes this properly. |
Before this change, a gem inside a rubygems source block that also defined a custom source, would cause subsequent gems inside that same block to be fetched from rubygems.org. For example: source "https://rubygems.org" source "https://foo.bar" do gem "rails", git: "[email protected]/rails/rails.git" gem "i18n" end In that case, i18n would be fetched from rubygems.org instead of foo.bar. Fixes #3974. Backport of #3978
Dsl#with_source should restore the previous source Fixes #3974.
Dsl#with_source should restore the previous source Before this change, a gem inside a rubygems source block that also defined a custom source, would cause subsequent gems inside that same block to be fetched from rubygems.org. For example: source "https://rubygems.org" source "https://foo.bar" do gem "rails", git: "[email protected]/rails/rails.git" gem "i18n" end In that case, i18n would be fetched from rubygems.org instead of foo.bar. Fixes #3974. Backport of #3978
Dsl#with_source should restore the previous source Before this change, a gem inside a rubygems source block that also defined a custom source, would cause subsequent gems inside that same block to be fetched from rubygems.org. For example: source "https://rubygems.org" source "https://foo.bar" do gem "rails", git: "[email protected]/rails/rails.git" gem "i18n" end In that case, i18n would be fetched from rubygems.org instead of foo.bar. Fixes #3974. Backport of #3978
If you reference a git repo inside of a source block, any gems after said git reference will be changed in
Gemfile.lock
.Example
Starting project, with the
Gemfile
andGemfile.lock
as expected:https://github.com/craig-day/bearded-nemesis
I have the base gems for a simple rails app in my
Gemfile
, then I also want to use https://rails-assets.org for my asset management, so I added a source block at the bottom to do so. All is fine and behaving expectedly.Example problem branch:
https://github.com/craig-day/bearded-nemesis/tree/broken_gemfile
This example seems like a silly thing to do, but it illustrates the point well. I added a gem with a git reference to the source block. If you look at the diff for
Gemfile.lock
(here) you will notice that it removed the!
from all of the gems referenced after the git reference.To put this into context, I can explain a real situation. At work we use a private gem server to host published gems, and Github to manage our git repos. In the normal situation, gems will get published to the gem server and all is well. If I want to test a gem feature branch for example, the simplest thing to do would be to tell that gem to reference the branch on Github. This works fine, but it makes unnecessary changes to the lock file. I would expect referencing git to only change the single gem I changed.
The text was updated successfully, but these errors were encountered: