bundler-patch 0.10.4 → 1.0.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 621d370daa4220636771b1cdada19350d866797f
4
- data.tar.gz: 694a377520e067ecc93690a7c7036f5046dc1702
3
+ metadata.gz: 28562c56f8a370cf07b84a98031b022906c83302
4
+ data.tar.gz: c8402af554da11c8e0296e9ded6f0d32221bc6b0
5
5
  SHA512:
6
- metadata.gz: df7910ec37f1ffd133e688db6d4252b3dac4d46ef52f311716f053c6b6a8cf35b5349643469aec956847497ace476415965e41dab5c4b32de01e3dd1163605df
7
- data.tar.gz: dbcbfed4101b53ff2209768ed4f05db5913f1d5380a64fd85a96309b4d30715fbb96d97e7fcf710a58f57d0d3436b4605e8e4087f60c11a339def376be5e68b5
6
+ metadata.gz: f6662076fad605bad8b8b01c0de0ab948416359ef80648a12b955e9911941ce230cd70cdb07e3f2fa19b52334577af091532fc80e08b89f58852c8ff6d66b8d5
7
+ data.tar.gz: cccc7f7319d86baa566f7121b1869036ee8d52f7a1a15ebf17d373f2c989896eedc98d03ec707d38ec8741bb0e1e799eb70b8ad2b6622c6c83dbeb18491e8303
data/.travis.yml CHANGED
@@ -9,19 +9,21 @@ script: bundle exec rake test:all
9
9
 
10
10
  matrix:
11
11
  include:
12
- - rvm: 2.1.10
13
- env: BUNDLER_TEST_VERSION=1.12.5
14
- - rvm: 2.2.5
15
- env: BUNDLER_TEST_VERSION=1.12.5
16
- - rvm: 2.3.1
12
+ - rvm: 2.3.4
17
13
  env: BUNDLER_TEST_VERSION=1.9.10
18
- - rvm: 2.3.1
14
+ - rvm: 2.3.4
19
15
  env: BUNDLER_TEST_VERSION=1.10.5
20
- - rvm: 2.3.1
16
+ - rvm: 2.3.4
21
17
  env: BUNDLER_TEST_VERSION=1.11.2
22
- - rvm: 2.3.1
18
+ - rvm: 2.3.4
23
19
  env: BUNDLER_TEST_VERSION=1.12.5
24
- - rvm: 2.3.1
25
- env: BUNDLER_TEST_VERSION=1.13.5
26
- - rvm: 2.3.3
27
- env: BUNDLER_TEST_VERSION=1.14.3
20
+ - rvm: 2.3.4
21
+ env: BUNDLER_TEST_VERSION=1.13.6
22
+ - rvm: 2.3.4
23
+ env: BUNDLER_TEST_VERSION=1.14.6
24
+ - rvm: 2.1.10
25
+ env: BUNDLER_TEST_VERSION=1.15.0
26
+ - rvm: 2.2.7
27
+ env: BUNDLER_TEST_VERSION=1.15.0
28
+ - rvm: 2.3.4
29
+ env: BUNDLER_TEST_VERSION=1.15.0
data/README.md CHANGED
@@ -3,14 +3,21 @@
3
3
  `bundler-patch` can update your gems conservatively to deal with vulnerable
4
4
  gems or just get more current.
5
5
 
6
- By default, "conservatively" means it will prefer the latest releases from the
7
- current version, over the latest minor releases or the latest major releases.
8
- This is somewhat opposite from `bundle update` which prefers newest/major
9
- versions first.
6
+ By default, "conservatively" means it will prefer the latest patch releases
7
+ from the current version, over the latest minor releases or the latest major
8
+ releases. This is somewhat opposite from `bundle update` which prefers
9
+ newest/major versions first.
10
+
11
+ Works with Bundler 1.9 and higher. Starting with Bundler 1.14 (undocumented in
12
+ 1.13), much of the core behavior in `bundler-patch` has been ported to Bundler
13
+ itself. See [Patch Level
14
+ Options](http://bundler.io/v1.14/man/bundle-update.1.html#PATCH-LEVEL-OPTIONS),
15
+ [Overlapping
16
+ Dependencies](http://bundler.io/v1.14/man/bundle-update.1.html#OVERLAPPING-DEPENDENCIES)
17
+ in the `bundle update` docs, also [Patch Level
18
+ Options](http://bundler.io/v1.14/man/bundle-outdated.1.html#PATCH-LEVEL-OPTIONS)
19
+ in the `bundle outdated` docs.
10
20
 
11
- Works with Bundler 1.9 and higher. Starting with Bundler 1.13, much of the
12
- core behavior in `bundler-patch` has been ported to Bundler itself. Read
13
- [BUNDLER.md](BUNDLER.md) for more information.
14
21
 
15
22
  [![Build Status](https://travis-ci.org/livingsocial/bundler-patch.svg?branch=master)](https://travis-ci.org/livingsocial/bundler-patch)
16
23
 
@@ -30,14 +37,15 @@ made.
30
37
 
31
38
  $ bundle patch
32
39
 
33
- "Conservatively" means it will sort all available versions to prefer the
34
- latest releases from the current version, then the latest minor releases and
40
+ "Conservatively" means it will sort all available versions to prefer the latest
41
+ patch releases from the current version, then the latest minor releases and
35
42
  then the latest major releases.
36
43
 
37
44
  "Prefer" means that no available versions are removed from consideration*, to
38
45
  help ensure a suitable dependency graph can be reconciled. This does mean some
39
- gems cannot be upgraded or may be upgraded to unexpected versions. NOTE: There is
40
- a `--strict_updates` option which _will_ remove versions from consideration, see below.
46
+ gems cannot be upgraded or may be upgraded to unexpected versions. NOTE: There
47
+ is a `--strict` option which _will_ remove versions from consideration,
48
+ see below.
41
49
 
42
50
  _*That's a white-lie. bundler-patch will actually remove from consideration
43
51
  any versions older than the currently locked version, which `bundle update`
@@ -45,8 +53,9 @@ will not do. It's not common, but it is possible for `bundle update` to
45
53
  regress a gem to an older version, if necessary to reconcile the dependency
46
54
  graph._
47
55
 
48
- Gem requirements as defined in the Gemfile will still define what versions are available.
49
- The new conservative behavior controls the preference order of those versions.
56
+ Gem requirements as defined in the Gemfile will still define what versions are
57
+ available. The new conservative behavior controls the preference order of those
58
+ versions.
50
59
 
51
60
  For example, if gem 'foo' is locked at 1.0.2, with no gem requirement defined
52
61
  in the Gemfile, and versions 1.0.3, 1.0.4, 1.1.0, 1.1.1, 2.0.0 all exist, the
@@ -62,18 +71,17 @@ gems.
62
71
 
63
72
  $ bundle patch foo bar
64
73
 
65
- * `-m/--minor_preferred` option will give preference for minor versions over
66
- release versions.
74
+ * `-m/--minor` option will give preference for minor versions over patch
75
+ versions.
67
76
 
68
- * `-p/--prefer_minimal` option will reverse the preference order within
69
- release, minor, major groups to just 'the next' version. In the prior
70
- example, the order of preference changes to "1.0.3, 1.0.4, 1.0.2, 1.1.0,
71
- 1.1.1, 2.0.0"
77
+ * `-n/--minimal` option will reverse the preference order within patch,
78
+ minor, major groups to just 'the next' version. In the prior example, the
79
+ order of preference changes to "1.0.3, 1.0.4, 1.0.2, 1.1.0, 1.1.1, 2.0.0"
72
80
 
73
- * `-s/--strict_updates` option will actually remove from consideration
74
- versions outside either the current release (or minor version if `-m`
75
- specified). This increases the chances of Bundler being unable to
76
- reconcile the dependency graph and could raise a `VersionConflict`.
81
+ * `-s/--strict` option will actually remove from consideration versions
82
+ outside either the current patch version (or minor version if `-m`
83
+ specified). This increases the chances of Bundler being unable to reconcile
84
+ the dependency graph and could raise a `VersionConflict`.
77
85
 
78
86
  `bundler-patch` will also check for vulnerabilities based on the
79
87
  `ruby-advisory-db`, but also will _modify_ (if necessary) the gem requirement
@@ -82,22 +90,36 @@ in the Gemfile on vulnerable gems to ensure they can be upgraded.
82
90
  * `-l/--list` option will just list vulnerable gems. No updates will be
83
91
  performed.
84
92
 
85
- * `-a/--advisory_db_path` option can provide the path to an additional
93
+ * `-a/--advisory-db-path` option can provide the path to an additional
86
94
  custom ruby-advisory-db styled directory. The path should not include the
87
95
  final `gems` directory, that will be appended automatically. This can be
88
96
  used for flagging necessary updates for custom/internal gems.
97
+
98
+ * `-d/--ruby-advisory-db-path` option can override the default path where the
99
+ ruby-advisory-db repository is checked out into.
89
100
 
90
101
  The rules for updating vulnerable gems are almost identical to the general
91
102
  `bundler-patch` behavior described above, and abide by the same options (`-m`,
92
- `-p`, and `-s`) though there are some tweaks to encourage getting to at least
103
+ `-n`, and `-s`) though there are some tweaks to encourage getting to at least
93
104
  a patched version of the gem. Keep in mind Bundler may still choose unexpected
94
105
  versions in order to satisfy the dependency graph.
95
106
 
96
- * `-v/--vulnerable_gems_only` option will automatically restrict the gems
107
+ * `-v/--vulnerable-gems-only` option will automatically restrict the gems
97
108
  to update list to currently vulnerable gems. If a combination of `-v` and
98
109
  a list of gem names are passed, the `-v` option is ignored in favor of
99
110
  the listed gem names.
100
111
 
112
+ `bundler-patch` can also update the Ruby version listed in .ruby-version and
113
+ the Gemfile if given a list of the latest Ruby versions that are available with
114
+ the following options. Jumps of major versions will not be made at all and this
115
+ feature is designed such that the version will be updated to only the next
116
+ available in the list. If the current version is 2.3.1, and the list of
117
+ `--rubies` is "2.3.2, 2.3.3", then 2.3.2 will be used, not 2.3.3. The intention
118
+ is for this list to be only the most recent version(s) of Ruby supported, (e.g.
119
+ "2.1.10, 2.2.7, 2.3.4").
120
+
121
+ * `-r/--ruby` option indicates updates to Ruby version will be made.
122
+ * `--rubies` a comma-delimited list of target Ruby versions to upgrade to.
101
123
 
102
124
  ## Examples
103
125
 
@@ -107,8 +129,8 @@ versions in order to satisfy the dependency graph.
107
129
  |-------------|---------|-----------------------------|----------|--------|
108
130
  | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1 | | 1.4.5 |
109
131
  | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1 | -m | 1.5.1 |
110
- | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1 | -p | 1.4.4 |
111
- | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1 | -m -p | 1.5.0 |
132
+ | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1 | -n | 1.4.4 |
133
+ | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1 | -m -n | 1.5.0 |
112
134
 
113
135
  ### Two Gems
114
136
 
@@ -131,21 +153,24 @@ Gemfile.lock:
131
153
  bar (~> 2.0)
132
154
  bar (2.0.3)
133
155
 
134
- | # | Command Line | Result |
135
- |---|---------------------------|---------------------------|
136
- | 1 | bundle patch | 'foo 1.4.5', 'bar 2.1.1' |
137
- | 2 | bundle patch foo | 'foo 1.4.4', 'bar 2.0.3' |
138
- | 3 | bundle patch -m | 'foo 1.5.1', 'bar 3.0.0' |
139
- | 4 | bundle patch -m -s | 'foo 1.5.0', 'bar 2.1.1' |
140
- | 5 | bundle patch -s | 'foo 1.4.4', 'bar 2.0.4' |
141
- | 6 | bundle patch -p | 'foo 1.4.4', 'bar 2.0.4' |
142
- | 7 | bundle patch -p -m | 'foo 1.5.0', 'bar 2.1.0' |
156
+ | # | Command Line | Result |
157
+ |---|---------------------------------|---------------------------|
158
+ | 1 | bundle patch | 'foo 1.4.5', 'bar 2.1.1' |
159
+ | 2 | bundle patch foo | 'foo 1.4.5', 'bar 2.1.1' |
160
+ | 3 | bundle patch --minor | 'foo 1.5.1', 'bar 3.0.0' |
161
+ | 4 | bundle patch --minor --strict | 'foo 1.5.0', 'bar 2.1.1' |
162
+ | 5 | bundle patch --strict | 'foo 1.4.4', 'bar 2.0.4' |
163
+ | 6 | bundle patch --minimal | 'foo 1.4.4', 'bar 2.0.4' |
164
+ | 7 | bundle patch --strict foo | 'foo 1.4.4', 'bar 2.0.3' |
165
+ | 8 | bundle patch --minimal --minor | 'foo 1.5.0', 'bar 2.1.0' |
143
166
 
144
167
  In case 1, `bar` is upgraded to 2.1.1, a minor version increase, because the
145
168
  dependency from `foo` 1.4.5 required it.
146
169
 
147
- In case 2, only `foo` is unlocked, so `foo` can only go to 1.4.4 to maintain
148
- the dependency to `bar`.
170
+ In case 2, `bar` still moves because it is not a _declared_ dependency in the
171
+ Gemfile, but it is a dependency of `foo` and is therefore free to move if
172
+ `foo`'s requirement of `bar` changes. If `bar` appeared in the Gemfile, then
173
+ it would stay put in this case and `foo` would only move to 1.4.4.
149
174
 
150
175
  In case 3, `bar` goes up a whole major release, because a minor increase is
151
176
  preferred now for `foo`, and when it goes to 1.5.1, it requires 3.0.0 of
@@ -159,14 +184,18 @@ In case 5, both `foo` and `bar` have any minor or major increments removed
159
184
  from consideration because of the `-s` strict flag, so the most they can
160
185
  move is up to 1.4.4 and 2.0.4.
161
186
 
162
- In case 6, the prefer minimal switch `-p` means they only increment to the
187
+ In case 6, the prefer minimal switch `-n` means they only increment to the
163
188
  next available release.
164
189
 
165
- In case 7, the `-p` and `-m` switches allow both to move to just the next
190
+ In case 7, the `-s` strict flag removes any `bar` 2.1 versions from
191
+ consideration, which restricts `foo` to 1.4.4 at latest. `bar` is not unlocked
192
+ and therefore doesn't move.
193
+
194
+ In case 8, the `-n` and `-m` switches allow both to move to just the next
166
195
  available minor version.
167
196
 
168
197
 
169
- ### Troubleshooting
198
+ ## Troubleshooting
170
199
 
171
200
  First, make sure the current `bundle` command itself runs to completion on its
172
201
  own without any problems.
@@ -211,18 +240,24 @@ At the end of all of this though, again, the requirements in the Gemfile
211
240
  trump anything else, and the most control you have is by modifying those
212
241
  in the Gemfile.
213
242
 
243
+ ## Breaking Changes from 0.x to 1.0
244
+
245
+ * Command line options with underscores now uses hyphens instead of
246
+ underscores. (Underscore versions will still work, but are undocumented).
247
+
248
+ * Some options have been renamed. (Old names will still work, but will be
249
+ undocumented).
250
+
251
+ * `--minor_preferred` => `--minor`
252
+ * `--prefer_minimal` => `--minimal` / `-p` => `-n`
253
+ * `--strict_updates` => `--strict`
254
+
255
+ In the "Two Gems" cases documented above, case 2 was _wrong_ (the docs were
256
+ incorrect, there was no bug in the code). Case 2 has been corrected and a
257
+ new similar case has been inserted towards the end of the table.
214
258
 
215
259
  ## Development
216
260
 
217
- ### Status
218
-
219
- 0.x versions are subject to breaking changes, there's a fair amount of
220
- experimenting going on.
221
-
222
- We'd love to get real world scenarios where things don't go as planned to help
223
- flesh out varying details of what many believe a conservative update should
224
- be.
225
-
226
261
  ### How To
227
262
 
228
263
  After checking out the repo, run `bin/setup` to install dependencies. Then,
@@ -70,6 +70,7 @@ module Bundler::Patch
70
70
  class GemPatch
71
71
  include Comparable
72
72
 
73
+ # TODO: requested_version is better name than new_version?
73
74
  attr_reader :gem_name, :old_version, :new_version, :patched_versions
74
75
 
75
76
  def initialize(gem_name:, old_version: nil, new_version: nil, patched_versions: nil)
@@ -7,18 +7,25 @@ module Bundler::Patch
7
7
  class CLI
8
8
  def self.execute
9
9
  opts = Slop.parse! do
10
- banner "Bundler Patch Version #{Bundler::Patch::VERSION}\nUsage: bundle patch [options] [gems_to_update]\n\nbundler-patch attempts to update gems conservatively.\n"
11
- on '-m', '--minor_preferred', 'Prefer update to the latest minor.release version.'
12
- on '-p', '--prefer_minimal', 'Prefer minimal version updates over most recent release (or minor if -m used).'
13
- on '-s', '--strict_updates', 'Restrict any gem to be upgraded past most recent release (or minor if -m used).'
10
+ banner "Bundler Patch Version #{Bundler::Patch::VERSION}\nUsage: bundle patch [options] [gems-to-update]\n\nbundler-patch attempts to update gems conservatively.\n"
11
+ on '-m', '--minor', 'Prefer update to the latest minor.patch version.'
12
+ on '-n', '--minimal', 'Prefer minimal version updates over most recent patch (or minor if -m used).'
13
+ on '-s', '--strict', 'Restrict any gem to be upgraded past most recent patch (or minor if -m used).'
14
14
  on '-l', '--list', 'List vulnerable gems and new version target. No updates will be performed.'
15
- on '-v', '--vulnerable_gems_only', 'Only update vulnerable gems.'
16
- on '-a=', '--advisory_db_path=', 'Optional custom advisory db path. `gems` dir will be appended to this path.'
17
- on '-d=', '--ruby_advisory_db_path=', 'Optional path for ruby advisory db. `gems` dir will be appended to this path.'
15
+ on '-v', '--vulnerable-gems-only', 'Only update vulnerable gems.'
16
+ on '-a=', '--advisory-db-path=', 'Optional custom advisory db path. `gems` dir will be appended to this path.'
17
+ on '-d=', '--ruby-advisory-db-path=', 'Optional path for ruby advisory db. `gems` dir will be appended to this path.'
18
18
  on '-r', '--ruby', 'Update Ruby version in related files.'
19
19
  on '--rubies=', 'Supported Ruby versions. Comma delimited or multiple switches.', as: Array, delimiter: ','
20
20
  on '-h', 'Show this help'
21
21
  on '--help', 'Show README.md'
22
+ # will be stripped in help display and normalized to hyphenated options
23
+ on '--vulnerable_gems_only'
24
+ on '--advisory_db_path='
25
+ on '--ruby_advisory_db_path='
26
+ on '-p', '--prefer_minimal'
27
+ on '--minor_preferred'
28
+ on '--strict_updates'
22
29
  end
23
30
 
24
31
  options = opts.to_hash
@@ -31,8 +38,9 @@ module Bundler::Patch
31
38
  CLI.new.patch(options)
32
39
  end
33
40
 
34
- def self.show_help(opts)
35
- puts opts
41
+ def self.show_help(slop)
42
+ slop.options.delete_if { |o| o.long =~ /_/ }
43
+ puts slop
36
44
  exit
37
45
  end
38
46
 
@@ -48,6 +56,8 @@ module Bundler::Patch
48
56
  def patch(options={})
49
57
  Bundler.ui = Bundler::UI::Shell.new
50
58
 
59
+ normalize_options(options)
60
+
51
61
  return list(options) if options[:list]
52
62
 
53
63
  patch_ruby(options[:rubies]) if options[:ruby]
@@ -55,6 +65,17 @@ module Bundler::Patch
55
65
  patch_gems(options)
56
66
  end
57
67
 
68
+ def normalize_options(options)
69
+ map = {:prefer_minimal => :minimal, :strict_updates => :strict, :minor_preferred => :minor}
70
+ {}.tap do |target|
71
+ options.each_pair do |k, v|
72
+ new_key = k.to_s.gsub('-', '_').to_sym
73
+ new_key = map[new_key] || new_key
74
+ target[new_key] = v
75
+ end
76
+ end
77
+ end
78
+
58
79
  private
59
80
 
60
81
  def list(options)
@@ -72,9 +72,9 @@ module Bundler::Patch
72
72
  @bundler_def ||= Bundler.definition(@gems_to_update.to_bundler_definition)
73
73
  @bundler_def.extend ConservativeDefinition
74
74
  @bundler_def.gems_to_update = @gems_to_update
75
- @bundler_def.strict = @options[:strict_updates]
76
- @bundler_def.minor_preferred = @options[:minor_preferred]
77
- @bundler_def.prefer_minimal = @options[:prefer_minimal]
75
+ @bundler_def.strict = @options[:strict]
76
+ @bundler_def.minor_preferred = @options[:minor]
77
+ @bundler_def.prefer_minimal = @options[:minimal]
78
78
  fixup_empty_remotes if @gems_to_update.to_bundler_definition === true
79
79
  @bundler_def
80
80
  end
@@ -105,6 +105,7 @@ module Bundler::Patch
105
105
 
106
106
  def initialize(gem_patches)
107
107
  @gem_patches = Array(gem_patches)
108
+ STDERR.puts "Unlocked gems: #{unlocking_description}" if ENV['DEBUG_PATCH_RESOLVER']
108
109
  end
109
110
 
110
111
  def to_bundler_definition
@@ -126,5 +127,9 @@ module Bundler::Patch
126
127
  def unlocking_gem?(gem_name)
127
128
  unlocking_all? || to_gem_names.include?(gem_name)
128
129
  end
130
+
131
+ def unlocking_description
132
+ unlocking_all? ? 'ALL' : to_gem_names.sort.join(', ')
133
+ end
129
134
  end
130
135
  end
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
2
  module Patch
3
- VERSION = '0.10.4'
3
+ VERSION = '1.0.0.pre.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 1.0.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrismo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-24 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler-advise
@@ -132,7 +132,6 @@ files:
132
132
  - ".rspec"
133
133
  - ".ruby-version"
134
134
  - ".travis.yml"
135
- - BUNDLER.md
136
135
  - Gemfile
137
136
  - LICENSE.txt
138
137
  - README.md
@@ -167,9 +166,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
166
  version: '0'
168
167
  required_rubygems_version: !ruby/object:Gem::Requirement
169
168
  requirements:
170
- - - ">="
169
+ - - ">"
171
170
  - !ruby/object:Gem::Version
172
- version: '0'
171
+ version: 1.3.1
173
172
  requirements: []
174
173
  rubyforge_project:
175
174
  rubygems_version: 2.6.8
data/BUNDLER.md DELETED
@@ -1,258 +0,0 @@
1
- # Conservative Bundle Updates
2
-
3
- Starting with 1.13.0.rc.2, a subset of bundler-patch behavior was ported to Bundler itself.
4
- The plan is to leave it undocumented and unsupported in 1.13 to give it a chance to
5
- be used and flush out bugs and iron out some design decisions.
6
-
7
- Part of that work before 1.14 (or maybe a later version) will be to properly document
8
- `bundle update` as well as the [Conservative Updating](http://bundler.io/v1.12/man/bundle-install.1.html#CONSERVATIVE-UPDATING)
9
- section of `bundle install`, but right now we need a placeholder document showing the new
10
- stuff so folks know how to use it.
11
-
12
- This is largely copy/pasta of the bundler-patch [README](README.md).
13
-
14
- ## Usage
15
-
16
- The default `bundle update` behavior remains untouched. Use of the new `--patch`
17
- or `--minor` options will invoke the new conservative update behavior.
18
-
19
- "Conservative" means it will sort all available versions to prefer the
20
- latest releases from the current version, then the latest minor releases and
21
- then the latest major releases.
22
-
23
- "Prefer" means that no available versions are removed from consideration, to
24
- help ensure a suitable dependency graph can be reconciled. This does mean some
25
- gems cannot be upgraded or may be upgraded to unexpected versions. NOTE: There is
26
- a `--strict` option which _will_ remove versions from consideration, see below.
27
-
28
- Gem requirements as defined in the Gemfile will still define what versions are available.
29
- The new conservative behavior controls the preference order of those versions.
30
-
31
- For example, if gem 'foo' is locked at 1.0.2, with no gem requirement defined
32
- in the Gemfile, and versions 1.0.3, 1.0.4, 1.1.0, 1.1.1, 2.0.0 all exist, the
33
- default order of preference will be "1.0.4, 1.0.3, 1.0.2, 1.1.1, 1.1.0,
34
- 2.0.0".
35
-
36
- In the same example, if gem 'foo' has a requirement of '~> 1.0', version 2.0.0
37
- will be removed from consideration as always.
38
-
39
- With no gem names provided on the command line, all gems will be unlocked and
40
- open for updating.
41
-
42
- $ bundle update --patch
43
-
44
- A list of gem names can be passed to restrict to just those gems.
45
-
46
- $ bundle update --patch foo bar
47
-
48
- * `--patch` option will give preference for release/patch versions, then minor,
49
- then major.
50
-
51
- * `--minor` option will give preference for minor versions over
52
- release versions, then major versions.
53
-
54
- * `--major` option will give preference for major versions over
55
- minor or release versions. This is the default behavior currently, so this
56
- flag is cosmetic for now. Bundler 2.0 will likely make `--patch` the default
57
- behavior.
58
-
59
- * `--strict` option will actually remove from consideration
60
- versions outside either the current release (or minor version if `--minor`
61
- specified). This increases the chances of Bundler being unable to
62
- reconcile the dependency graph and in some cases could even raise a
63
- `VersionConflict`.
64
-
65
- ## Examples
66
-
67
- ### Single Gem
68
-
69
- | Requirements| Locked | Available | Option | Result |
70
- |-------------|---------|-----------------------------------|----------|--------|
71
- | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1, 2.0.0 | --patch | 1.4.5 |
72
- | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1, 2.0.0 | --minor | 1.5.1 |
73
- | foo | 1.4.3 | 1.4.4, 1.4.5, 1.5.0, 1.5.1, 2.0.0 | --major | 2.0.0 |
74
-
75
- ### Two Gems
76
-
77
- Given the following gem specifications:
78
-
79
- - foo 1.4.3, requires: ~> bar 2.0
80
- - foo 1.4.4, requires: ~> bar 2.0
81
- - foo 1.4.5, requires: ~> bar 2.1
82
- - foo 1.5.0, requires: ~> bar 2.1
83
- - foo 1.5.1, requires: ~> bar 3.0
84
- - bar with versions 2.0.3, 2.0.4, 2.1.0, 2.1.1, 3.0.0
85
-
86
- Gemfile:
87
-
88
- gem 'foo'
89
-
90
- Gemfile.lock:
91
-
92
- foo (1.4.3)
93
- bar (~> 2.0)
94
- bar (2.0.3)
95
-
96
- | # | Command Line | Result |
97
- |---|--------------------------------|---------------------------|
98
- | 1 | bundle update --patch | 'foo 1.4.5', 'bar 2.1.1' |
99
- | 2 | bundle update --patch foo | 'foo 1.4.5', 'bar 2.1.1' |
100
- | 3 | bundle update --minor | 'foo 1.5.1', 'bar 3.0.0' |
101
- | 4 | bundle update --minor --strict | 'foo 1.5.0', 'bar 2.1.1' |
102
- | 5 | bundle update --patch --strict | 'foo 1.4.4', 'bar 2.0.4' |
103
-
104
- In case 1, `bar` is upgraded to 2.1.1, a minor version increase, because the
105
- dependency from `foo` 1.4.5 required it.
106
-
107
- In case 2, only `foo` is unlocked, but because no other gem depends on `bar`
108
- and `bar` is not a declared dependency in the Gemfile, `bar` is free to move,
109
- and so the result is the same as case 1.
110
-
111
- In case 3, `bar` goes up a whole major release, because a minor increase is
112
- preferred now for `foo`, and when it goes to 1.5.1, it requires 3.0.0 of
113
- `bar`.
114
-
115
- In case 4, `foo` is preferred up to a 1.5.x, but 1.5.1 won't work because the
116
- `--strict` flag removes `bar` 3.0.0 from consideration since it's a major
117
- increment.
118
-
119
- In case 5, both `foo` and `bar` have any minor or major increments removed
120
- from consideration because of the `--strict` flag, so the most they can
121
- move is up to 1.4.4 and 2.0.4.
122
-
123
- ### Shared Dependencies
124
-
125
- #### Shared Cannot Move
126
-
127
- Given the following gem specifications:
128
-
129
- - foo 1.4.3, requires: ~> shared 2.0, ~> bar 2.0
130
- - foo 1.4.4, requires: ~> shared 2.0, ~> bar 2.0
131
- - foo 1.4.5, requires: ~> shared 2.1, ~> bar 2.1
132
- - foo 1.5.0, requires: ~> shared 2.1, ~> bar 2.1
133
- - qux 1.0.0, requires: ~> shared 2.0.0
134
- - bar with versions 2.0.3, 2.0.4, 2.1.0, 2.1.1
135
- - shared with versions 2.0.3, 2.0.4, 2.1.0, 2.1.1
136
-
137
- Gemfile:
138
-
139
- gem 'foo'
140
- gem 'qux'
141
-
142
- Gemfile.lock:
143
-
144
- bar (2.0.3)
145
- foo (1.4.3)
146
- bar (~> 2.0)
147
- shared (~> 2.0)
148
- qux (1.0.0)
149
- shared (~> 2.0.0)
150
- shared (2.0.3)
151
-
152
-
153
- | # | Command Line | Result |
154
- |---|--------------------------------|-------------------------------------------|
155
- | 1 | bundle update --patch foo | 'foo 1.4.4', 'bar 2.0.3', 'shared 2.0.3' |
156
- | 2 | bundle update --patch foo bar | 'foo 1.4.4', 'bar 2.0.4', 'shared 2.0.3' |
157
- | 3 | bundle update --patch | 'foo 1.4.4', 'bar 2.0.4', 'shared 2.0.4' |
158
-
159
- In case 1, only `foo` moves. When `foo` 1.4.5 is considered in resolution, it
160
- would require `shared` 2.1 which isn't allowed because `qux` is incompatible.
161
- Resolution backs up to `foo` 1.4.4, and that is allowed by the `qux` constraint
162
- on `shared` so `foo` moves. `bar` could legally move, but since it is locked
163
- and the current version still satisfies the requirement of `~> 2.0` it stays
164
- put.
165
-
166
- In case 2, everything is the same, but `bar` is also unlocked, so it is also
167
- allowed to increment to 2.0.4 which still satisfies `~> 2.0`.
168
-
169
- In case 3, everything is unlocked, so `shared` can also bump up a patch version.
170
-
171
- #### Shared Can Move
172
-
173
- _*This is exactly the same setup as "Shared Cannot Move" except for one change:*_
174
- The `qux` gem has a looser requirement of `shared`: `~> 2.0` instead of `~> 2.0.0`.
175
-
176
- Given the following gem specifications:
177
-
178
- - foo 1.4.3, requires: ~> shared 2.0, ~> bar 2.0
179
- - foo 1.4.4, requires: ~> shared 2.0, ~> bar 2.0
180
- - foo 1.4.5, requires: ~> shared 2.1, ~> bar 2.1
181
- - foo 1.5.0, requires: ~> shared 2.1, ~> bar 2.1
182
- - qux 1.0.0, requires: ~> shared 2.0
183
- - bar with versions 2.0.3, 2.0.4, 2.1.0, 2.1.1
184
- - shared with versions 2.0.3, 2.0.4, 2.1.0, 2.1.1
185
-
186
- Gemfile:
187
-
188
- gem 'foo'
189
- gem 'qux'
190
-
191
- Gemfile.lock:
192
-
193
- bar (2.0.3)
194
- foo (1.4.3)
195
- bar (~> 2.0)
196
- shared (~> 2.0)
197
- qux (1.0.0)
198
- shared (~> 2.0)
199
- shared (2.0.3)
200
-
201
-
202
- | # | Command Line | Result |
203
- |---|--------------------------------|-------------------------------------------|
204
- | 1 | bundle update --patch foo | 'foo 1.4.5', 'bar 2.1.1', 'shared 2.1.1' |
205
- | 2 | bundle update --patch foo bar | 'foo 1.4.5', 'bar 2.1.1', 'shared 2.1.1' |
206
- | 3 | bundle update --patch | 'foo 1.4.5', 'bar 2.1.1', 'shared 2.1.1' |
207
-
208
- In all 3 cases, because `foo` 1.4.5 depends on newer versions of `bar` and
209
- `shared`, and no requirements from `qux` are restricting those two from moving,
210
- then all move as far as allowed here.
211
-
212
- `foo` can only move to 1.4.5 and not 1.5.0 because of the `--patch` flag.
213
-
214
- As previously demonstrated (see Two Cases) `bar` and `shared` move past the
215
- `--patch` restriction because `--strict` is not in play, they are not declared
216
- dependencies in the Gemfile and they need to move to satisfy the new `foo`
217
- requirement.
218
-
219
- ### Bundle Install Like Conservative Updating
220
-
221
- As detailed in [Bundle Install Docs](http://bundler.io/v1.13/man/bundle-install.1.html#CONSERVATIVE-UPDATING)
222
- there is a way to prevent shared dependencies from moving after (a) changing
223
- a requirement in the Gemfile and (b) using `bundle install`. There's currently
224
- not an equivalent way to do this with `bundler-patch` or `bundle update` but
225
- this may change in the future.
226
-
227
- ### Troubleshooting
228
-
229
- First, make sure the current `bundle` command itself runs to completion on its
230
- own without any problems.
231
-
232
- The most frequent problems involve expectations around what
233
- gems should or shouldn't be upgraded. This can quickly get complicated as even
234
- a small dependency tree can involve many moving parts, and Bundler works hard
235
- to find a combination that satisfies all of the dependencies and requirements.
236
-
237
- NOTE: the requirements in the Gemfile trump anything else. The most control
238
- you have is by modifying those in the Gemfile, in some circumstances it may be
239
- better to pin your versions to what you need instead of trying to diagnose why
240
- Bundler isn't calculating the versions you expect with a broader requirement.
241
- If there is an incompatibility, pinning to desired versions can also aide in
242
- debugging dependency conflicts.
243
-
244
- You can get a (very verbose) look into how Bundler's resolution algorithm is
245
- working by setting the `DEBUG_RESOLVER` environment variable. While it can be
246
- tricky to dig through, it should explain how it came to the conclusions it
247
- came to.
248
-
249
- In particular, grep for 'Unwinding for conflict' in the debug output to
250
- isolate some key issues that may be preventing the outcome you expect.
251
-
252
- To get additional Bundler debugging output, enable the `DEBUG` env variable.
253
- This will include all of the details of the downloading the full dependency
254
- data from remote sources.
255
-
256
- At the end of all of this though, again, the requirements in the Gemfile
257
- trump anything else, and the most control you have is by modifying those
258
- in the Gemfile.