-
-
Notifications
You must be signed in to change notification settings - Fork 2k
bundle update --source gem
updates conservatively
#3759
Comments
I was surprised to learn that it worked, but I also didn't write that code, so I can't really tell you whether it was intentional or not. Your code archaeology is top-notch, and I really appreciate how well you documented your question. :) At this point, removing it would break backwards compatibility, so we're not going to take it out until 2.0. That said, I would strongly prefer to have a documented |
This is indeed a really nice read of an issue @neoeno. One of my co-workers showed me this trick to update conservatively with Anyway, I totally agree the name of this "conservatively update" feature should change to something like @indirect are you sure about not extending the documentation for |
Sorry, I guess I wasn't clear. I would love to document it. At the same time, we might as well change the option name to '--only' by adding an alias now, and then when we separate the source and only code paths, they will be documented as separate. :) |
Since we're talking thought I'd drop in an update: started working on the resolution @indirect proposed in #3763 — but ran into another strange result when using |
So the behaviour of Passing a gem to the source option will update a gem and all of its dependencies except those that are specified elsewhere in the Gemfile or are depended on by other gems. In practice, in a project above a given level of complexity (e.g. most Rails projects) any given gem is likely to appear somewhere else in the dependency graph — so will remain locked. I'm finishing up some changes to #3763 that include tests for this behaviour. |
awesome, thanks! On Sun, Jul 12, 2015 at 1:30 PM, Caden Lovelace [email protected]
|
Fix `--source` option causing incorrect gem unlocking Fixes #3759 and #3761. And also another issue I found where if: 1. You have a Gemfile with a group, 2. That group contains a gem with the same name as a source 3. And you run `bundle update --group group_name` 4. Then all gems associated with the source will be updated. The 3 cases fixed here are all pretty subtle. The specs should make it clearer, and the github issues above add more context. Note that this PR removes the ability to use `bundle update --source gem_name` as a hacky way to update a gem 'conservatively'. This is detailed in #3759.
I've written up, with some code samples, more details on the stuff @neoeno dug up, if anyone is curious: https://github.com/chrismo/bundler-source-hack |
@chrismo I'm pretty interested in the possibility of |
Sure thing 👍 |
@indirect, regarding your comment about update --only option #3759 (comment), would you be willing/interested to merge/see a PR for such a feature? Or is there already some awesome features on the pipeline for 2.0 regarding this? |
As noted in #2016, using
bundle update --source gem
appears to do the same asbundle update gem
while refusing to unlock any of the gems' dependencies. It's becoming a more popular technique.Some people consider this useful behaviour, but the docs don't seem to indicate that this is intended behaviour. The docs say:
This would appear to be intended to allow git sources to be unlocked. I reason this way because of the comment and code in definition.rb:
Which is fine. The question is — what does this code do when
--source
is passed a rubygem rather than a git gem. It does nothing — becauselib/bundler/source/rubygems.rb
doesn't have#unlock!
.So, by that reasoning,
bundle update --source rubygem_gem
should be a no-op. But it isn't.So, I found definition.rb line 529 in #converge_locked_specs:
When we run
bundle update --source rubygem_gem
ands.name == 'rubygem_gem'
—s.source
is not nil@unlock[:sources]
is['rubygem_gem']
Therefore the condition returns true and the result of all this is that
#converge_locked_specs
returns aSpecSet
that omitsrubygem_gem
. This means that the gem is effectively unlocked, allowing it to be updated on its own without having any of its dependencies unlocked.All beyond this line is speculation:
I looked for the commit where this was introduced, and found this commit back in 2010.. It's a little hard to work out what's equivalent, but I found this removal in
#converge
:Which would seem to go through locked specs, try to find their source, and if it can't find it then unlock the spec.
Correspondingly, this addition in
#converge_locked_specs
:Which would seem to go through locked specs, and delete them if the source is nil, or if
@unlock[:sources]
contains... the spec name? Seems unexpected. Shouldn't that be the source name? It could be unintended.So, I've no strong opinion on whether you should be able to 'update conservatively', but if the functionality is there it should probably be documented as such.
Sorry for the long read! Hope it was clear.
The text was updated successfully, but these errors were encountered: