-
-
Notifications
You must be signed in to change notification settings - Fork 2k
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Way to bundle update conservatively a single gem #2016
Comments
Rails (the gem) does not conform to Semantic Versioning, and therefore the best practice is to explicitly state which version of Rails your application is compatible with in your Gemfile. Bundler will honor explicit versions set in the Gemfile, even while you run In the case of gems other than Rails, we strongly recommend that you update a gem's dependencies when you update that gem, which is why the Thanks for the suggestion, and I hope that the explanation of locking Rails via a version in the Gemfile addresses your issue. |
+1 for "bundle update [some gem] [--conservative]" (where '--conservative' can only be added when a gem name is specified on the bundle update command). I think this is a reasonable feature request by @marcandre This would simply be a time-saving bit of sugar, to be able to conservatively update a particular gem, without having to edit the Gemfile, bundle install, then undo the edits to the Gemfile. Or worse, result in devs fiddling with their Gemfile.lock (see Options 1 & 3 in this post). Regardless of whether this is rails, or any other gem. Use case: My company's internal gem works with any version of rails, and any version of many other gems it depends on. But when my team updates to the latest version of my internal (company specific, private) gem, they don't always want to change any other code in related gems, but just get my internal gem updates. This would allow them to do this in the most conservative way possible, and make it easier than the process described, which works of course, but is a bit of a pain, particularly when working with internal gems which are updated often to get company specific business logic/functionality. Thanks for listening! |
There is reputedly a way to do this in bundler via the --source option: bundle update --source=some_gem I say reputedly because I am unable to get it to work for the xpath gem but this problem may be specific to that gem. |
My understanding is that --source is simply for specifying the source (URL or local filesystem) location where any needed gems can be found. @byrnejb : Do you have a link to a blog post or other explaining how |
P.S. If you run bundle update --source gem_name and gem_name is not updated then gem_name has other dependencies which differ from those already locked. You will have to discover which of these dependencies must be updated to allow gem_name to update as well. it is quite possible to get into a vicious cycle where one cannot update a particular gem because its dependency versions conflict with those required by a different gem that one does not wish to update. |
For anyone who runs into this, updating in my Gemfile (in my case from a branch to merged master) and |
I'll just put in another plug for adding a '--conservative' option for bundler when updating single gems. Anytime you have users having to edit a file, re-run a command, then revert changes to the edits, seems like a slam dunk for a nice convenient command line option. Anyway, that's imo of course. |
So help me understand exactly what you want, then, I guess? You want to be able to run Could this instead be solved by interactive update mode, like https://github.com/wireframe/bundler-updater? |
No, not quite. It has to update to the latest Update Other way to say this: equivalent of If you want a concrete example:
I'd like a single command line call that will change the I consider it a bug that (I've taken an example with Rails, but this has nothing to do with Rails) |
If you care about the versions of implicit dependencies, you should make those dependencies explicit in your own Gemfile. |
That won't fix it. Even if the dependency is explicit, say in my example above I have a |
I see what you're saying now. Conservative update for all child dependencies, along with aggressive update for the top level dependency, sounds like the way to go. That also sounds very, very hard to get right. :)
|
😄
I haven't looked at the code, but I'm surprised this looks hard to get right.
|
+1 for this request. We do very conservative gem updates in our environment so it's always a surprise when bundler updates dependencies unnecessarily! |
|
👍 |
@indirect What are the difficult parts with @marcandre's suggestion? Where
|
@indirect, 6 Jul 2012
Er... no. I am updating
And then, according to your instructions, I'm supposed to run:
So that doesn't work. If I do
I don't want all the rest! I had to manually figure out in each case whether the change was actually needed, and then revert parts of my |
@pjscopeland you should be able to get that exact behavior today by running |
Well
And |
Sorry, it's |
Here's an explanation of how --source updating works: http://ilikestuffblog.com/2012/07/01/you-should-update-one-gem-at-a-time-with-bundler-heres-how/ |
Yup found that. Though |
Found a place the faked source was being merged with the one read from the lockfile, so now tests that want to simulate that case will work. This also adds a spec that demonstrates how `bundle update foo` will also grab an update to any gems `foo` depends on, even though we didn't request that. This refers to the conservative idea that has been floated around the 'net. rubygems/bundler#2016 http://makandracards.com/makandra/13885-how-to-update-a-single-gem-conservatively
I've been messing around with this for a while, just released 0.7.0 of a gem today, would love feedback: https://github.com/livingsocial/bundler-patch |
An old ticket, but a ways back @indirect says:
That's how I thought it worked, and I swear it's worked this way for me before (maybe back in 2012), but today it does not seem to. I edit my
This surprised me. Of course, if I run Of course, this case may be complicated by the fact that "rails" has it's own dependencies, on activerecord etc, that of course will need to be updated too to get a resolution. But I thought this had worked for me before. Anyone know what's up? |
@jrochkind I couldn't recreate with just a simple Gemfile with just gem 'rails' in it ... but that's not valid, the regular Gemfile would need to be considered. Anything you can link to in a gist? |
Bundler now has some new flags for conservative updates, would love y'alls feedback: rubygems/bundler-features#122 |
@chrismo I don't have a simple repro, sorry, these things tend to occur in complicated gem files. And I think I've lost the gemfile/gemfile.lock that happened in, don't remember what project of mine anymore either. But I have had this problem fairly regularly. Next time it happens, is it useful if I file a fresh issue, with the complete Gemfile/Gemfile.lock even if it's complicated? What keeps me from filing in the past is not even being sure if what I'm seeing is somehow expected behavior (in the past, there have been things I was sure were rubygems bugs, that I was told was not a bug upon reporting), or not having any idea if such reports are welcome and will get any attention at all. |
Yeah, definitely. Happy to try and diagnose a weird case. 👻 |
@chrismo Okay if it happens again, I'll file an issue! So long as we are agreed that the expected/intended behavior is:
I have to admit I don't understand what the docs at rubygems/bundler-features#122 are describing, and I'm not sure if it's what others (and me) were actually wanting? Am I just not following the docs, or is it intended to be something differnet from what this issue is asking for? What this issue is asking for is related to the quote above, originally from indirect. Consider a Gemfile with lots of things in it, including What this issue is asking for is something similar, but without having to manually update the Gemfile. perhaps Of course it gets more complicated if more than one gem is involved But it's not clear to me that rubygems/bundler-features#122 is describing anything like this at all. It appears to be something different, involving minor/patch restrictions, which is not what this issue was asking for, and is not something that to me is obviously useful for my workflow anyway. |
Thx for the feedback, it's exactly the sort of stuff I was hoping we could flush out at this stage. "Conservative updates" appears to have varying meaning to folks and your reply plus the comments on 122 from yesterday are already drawing out some additional use cases that weren't at the forefront of my mind when I wrote what I did. If you're cool with it, I'd like to move this discussion over to that issue, so we can try to accumulate discussion there. I'm also curious if the existing comments there overlap with how you'd like things to work. In particular, this case: rubygems/bundler-features#122 (comment) |
I just ran into the exact problem that the original comments on this thread were describing: I had a very old project that needed a single gem updated to its latest version to pull in a fix for a bug in that gem, but every combination of |
If
some_gem
is already installed, and I want the latest version of it,bundle install
will not do anything andbundle update some_gem
will updatesome_gem
(yay!) but also any of its dependency (not what I want). I'd rather not update my rails version just because I'm also updating a minor gem that has rails as a dependency.Only current way is to go in the Gemfile and manually state that we want a version
>= current_version
, and nowbundle install
will update it.It would be awesome to be able to update
some_gem
and be conservative for the rest, without having to state an actual version in the Gemfile.BTW, I don't understand the reason behind the decision that
bundle update foo
is not conservative; this won't happen when I bundle install and have addedsome_gem
line in my Gemfile, or increased the minimum version for that gem. In any case, a--conservative
or something would be greatly appreciated.This is a repost of #2011
The text was updated successfully, but these errors were encountered: