bundler 2.2.11 → 2.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +721 -5
  3. data/README.md +1 -1
  4. data/bundler.gemspec +8 -11
  5. data/exe/bundle +7 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/cli/cache.rb +1 -1
  10. data/lib/bundler/cli/check.rb +4 -2
  11. data/lib/bundler/cli/common.rb +17 -3
  12. data/lib/bundler/cli/config.rb +10 -1
  13. data/lib/bundler/cli/doctor.rb +24 -5
  14. data/lib/bundler/cli/exec.rb +1 -6
  15. data/lib/bundler/cli/gem.rb +130 -26
  16. data/lib/bundler/cli/info.rb +27 -6
  17. data/lib/bundler/cli/init.rb +5 -1
  18. data/lib/bundler/cli/install.rb +23 -54
  19. data/lib/bundler/cli/issue.rb +4 -3
  20. data/lib/bundler/cli/list.rb +7 -1
  21. data/lib/bundler/cli/lock.rb +5 -1
  22. data/lib/bundler/cli/open.rb +1 -2
  23. data/lib/bundler/cli/outdated.rb +22 -14
  24. data/lib/bundler/cli/platform.rb +2 -2
  25. data/lib/bundler/cli/remove.rb +1 -2
  26. data/lib/bundler/cli/show.rb +1 -1
  27. data/lib/bundler/cli/update.rb +17 -8
  28. data/lib/bundler/cli.rb +51 -63
  29. data/lib/bundler/compact_index_client/cache.rb +0 -9
  30. data/lib/bundler/compact_index_client/updater.rb +26 -14
  31. data/lib/bundler/compact_index_client.rb +2 -8
  32. data/lib/bundler/current_ruby.rb +17 -6
  33. data/lib/bundler/definition.rb +260 -362
  34. data/lib/bundler/dependency.rb +23 -71
  35. data/lib/bundler/digest.rb +71 -0
  36. data/lib/bundler/dsl.rb +72 -76
  37. data/lib/bundler/endpoint_specification.rb +19 -13
  38. data/lib/bundler/env.rb +1 -1
  39. data/lib/bundler/environment_preserver.rb +4 -1
  40. data/lib/bundler/errors.rb +29 -3
  41. data/lib/bundler/feature_flag.rb +0 -5
  42. data/lib/bundler/fetcher/base.rb +6 -8
  43. data/lib/bundler/fetcher/compact_index.rb +10 -15
  44. data/lib/bundler/fetcher/downloader.rb +9 -6
  45. data/lib/bundler/fetcher/index.rb +0 -27
  46. data/lib/bundler/fetcher.rb +22 -23
  47. data/lib/bundler/friendly_errors.rb +26 -36
  48. data/lib/bundler/gem_helper.rb +21 -16
  49. data/lib/bundler/gem_helpers.rb +9 -2
  50. data/lib/bundler/gem_version_promoter.rb +14 -25
  51. data/lib/bundler/index.rb +11 -46
  52. data/lib/bundler/injector.rb +18 -4
  53. data/lib/bundler/inline.rb +4 -13
  54. data/lib/bundler/installer/gem_installer.rb +16 -21
  55. data/lib/bundler/installer/parallel_installer.rb +36 -15
  56. data/lib/bundler/installer/standalone.rb +42 -10
  57. data/lib/bundler/installer.rb +25 -41
  58. data/lib/bundler/lazy_specification.rb +52 -30
  59. data/lib/bundler/lockfile_generator.rb +2 -2
  60. data/lib/bundler/lockfile_parser.rb +18 -43
  61. data/lib/bundler/man/bundle-add.1 +21 -5
  62. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  63. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  64. data/lib/bundler/man/bundle-cache.1 +7 -1
  65. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  66. data/lib/bundler/man/bundle-check.1 +1 -1
  67. data/lib/bundler/man/bundle-clean.1 +2 -2
  68. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  69. data/lib/bundler/man/bundle-config.1 +49 -22
  70. data/lib/bundler/man/bundle-config.1.ronn +49 -30
  71. data/lib/bundler/man/bundle-console.1 +53 -0
  72. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  73. data/lib/bundler/man/bundle-doctor.1 +1 -1
  74. data/lib/bundler/man/bundle-exec.1 +2 -2
  75. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  76. data/lib/bundler/man/bundle-gem.1 +14 -1
  77. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  78. data/lib/bundler/man/bundle-help.1 +13 -0
  79. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  80. data/lib/bundler/man/bundle-info.1 +1 -1
  81. data/lib/bundler/man/bundle-init.1 +1 -1
  82. data/lib/bundler/man/bundle-inject.1 +5 -2
  83. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  84. data/lib/bundler/man/bundle-install.1 +6 -2
  85. data/lib/bundler/man/bundle-install.1.ronn +8 -2
  86. data/lib/bundler/man/bundle-list.1 +1 -1
  87. data/lib/bundler/man/bundle-lock.1 +1 -1
  88. data/lib/bundler/man/bundle-open.1 +1 -1
  89. data/lib/bundler/man/bundle-outdated.1 +3 -10
  90. data/lib/bundler/man/bundle-outdated.1.ronn +1 -10
  91. data/lib/bundler/man/bundle-platform.1 +16 -6
  92. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  93. data/lib/bundler/man/bundle-plugin.1 +81 -0
  94. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  95. data/lib/bundler/man/bundle-pristine.1 +1 -1
  96. data/lib/bundler/man/bundle-remove.1 +1 -1
  97. data/lib/bundler/man/bundle-show.1 +1 -1
  98. data/lib/bundler/man/bundle-update.1 +5 -5
  99. data/lib/bundler/man/bundle-update.1.ronn +5 -4
  100. data/lib/bundler/man/bundle-version.1 +35 -0
  101. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  102. data/lib/bundler/man/bundle-viz.1 +4 -1
  103. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  104. data/lib/bundler/man/bundle.1 +15 -10
  105. data/lib/bundler/man/bundle.1.ronn +12 -7
  106. data/lib/bundler/man/gemfile.5 +117 -80
  107. data/lib/bundler/man/gemfile.5.ronn +105 -84
  108. data/lib/bundler/man/index.txt +4 -0
  109. data/lib/bundler/match_metadata.rb +13 -0
  110. data/lib/bundler/match_platform.rb +0 -1
  111. data/lib/bundler/match_remote_metadata.rb +29 -0
  112. data/lib/bundler/plugin/api/source.rb +24 -8
  113. data/lib/bundler/plugin/index.rb +4 -1
  114. data/lib/bundler/plugin/installer/git.rb +0 -4
  115. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  116. data/lib/bundler/plugin/installer.rb +10 -10
  117. data/lib/bundler/plugin/source_list.rb +4 -0
  118. data/lib/bundler/plugin.rb +30 -8
  119. data/lib/bundler/process_lock.rb +1 -1
  120. data/lib/bundler/remote_specification.rb +10 -4
  121. data/lib/bundler/resolver/base.rb +50 -0
  122. data/lib/bundler/resolver/spec_group.rb +31 -73
  123. data/lib/bundler/resolver.rb +193 -292
  124. data/lib/bundler/retry.rb +1 -1
  125. data/lib/bundler/ruby_dsl.rb +1 -1
  126. data/lib/bundler/ruby_version.rb +5 -18
  127. data/lib/bundler/rubygems_ext.rb +160 -26
  128. data/lib/bundler/rubygems_gem_installer.rb +86 -9
  129. data/lib/bundler/rubygems_integration.rb +46 -93
  130. data/lib/bundler/runtime.rb +18 -12
  131. data/lib/bundler/self_manager.rb +168 -0
  132. data/lib/bundler/settings.rb +98 -22
  133. data/lib/bundler/setup.rb +2 -2
  134. data/lib/bundler/shared_helpers.rb +15 -31
  135. data/lib/bundler/source/git/git_proxy.rb +8 -6
  136. data/lib/bundler/source/git.rb +29 -13
  137. data/lib/bundler/source/metadata.rb +3 -7
  138. data/lib/bundler/source/path/installer.rb +1 -1
  139. data/lib/bundler/source/path.rb +3 -1
  140. data/lib/bundler/source/rubygems.rb +199 -182
  141. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  142. data/lib/bundler/source.rb +24 -4
  143. data/lib/bundler/source_list.rb +104 -60
  144. data/lib/bundler/source_map.rb +71 -0
  145. data/lib/bundler/spec_set.rb +58 -52
  146. data/lib/bundler/stub_specification.rb +13 -3
  147. data/lib/bundler/templates/Executable +2 -4
  148. data/lib/bundler/templates/Executable.bundler +8 -8
  149. data/lib/bundler/templates/Executable.standalone +2 -4
  150. data/lib/bundler/templates/Gemfile +0 -2
  151. data/lib/bundler/templates/gems.rb +0 -3
  152. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  153. data/lib/bundler/templates/newgem/README.md.tt +8 -12
  154. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  155. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +16 -7
  156. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +5 -4
  157. data/lib/bundler/templates/newgem/newgem.gemspec.tt +19 -17
  158. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  159. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  160. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  161. data/lib/bundler/ui/shell.rb +1 -1
  162. data/lib/bundler/vendor/.document +1 -0
  163. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  164. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  165. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  166. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  167. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  168. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  169. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  170. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -3
  171. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +32 -26
  172. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  173. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  174. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  175. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  176. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  177. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  178. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  179. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  180. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  181. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  182. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  183. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  184. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  185. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  186. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  187. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  188. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  189. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  190. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  191. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  192. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  193. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  194. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  195. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  196. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  197. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  198. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  199. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  200. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  201. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  202. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  203. data/lib/bundler/vendored_tsort.rb +4 -0
  204. data/lib/bundler/version.rb +1 -1
  205. data/lib/bundler/worker.rb +19 -4
  206. data/lib/bundler.rb +46 -39
  207. metadata +39 -12
  208. data/lib/bundler/dep_proxy.rb +0 -55
  209. data/lib/bundler/gemdeps.rb +0 -29
  210. data/lib/bundler/psyched_yaml.rb +0 -22
  211. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -8,10 +8,12 @@ module Bundler
8
8
  end
9
9
 
10
10
  def run
11
- Bundler.ui.level = "error" if options[:quiet]
11
+ Bundler.ui.level = "warn" if options[:quiet]
12
12
 
13
13
  warn_if_root
14
14
 
15
+ Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
16
+
15
17
  Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
16
18
 
17
19
  # Disable color in deployment mode
@@ -33,12 +35,8 @@ module Bundler
33
35
 
34
36
  options[:local] = true if Bundler.app_cache.exist?
35
37
 
36
- if Bundler.feature_flag.deployment_means_frozen?
37
- Bundler.settings.set_command_option :deployment, true
38
- else
39
- Bundler.settings.set_command_option :deployment, true if options[:deployment]
40
- Bundler.settings.set_command_option :frozen, true if options[:frozen]
41
- end
38
+ Bundler.settings.set_command_option :deployment, true if options[:deployment]
39
+ Bundler.settings.set_command_option :frozen, true if options[:frozen]
42
40
  end
43
41
 
44
42
  # When install is called with --no-deployment, disable deployment mode
@@ -62,7 +60,10 @@ module Bundler
62
60
  definition.validate_runtime!
63
61
 
64
62
  installer = Installer.install(Bundler.root, definition, options)
65
- Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
63
+
64
+ Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
65
+ Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
66
+ end
66
67
 
67
68
  Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
68
69
  Bundler::CLI::Common.output_without_groups_message(:install)
@@ -84,28 +85,15 @@ module Bundler
84
85
  end
85
86
 
86
87
  Bundler::CLI::Common.output_fund_metadata_summary
87
- rescue GemNotFound, VersionConflict => e
88
- if options[:local] && Bundler.app_cache.exist?
89
- Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
90
- end
91
-
92
- unless Bundler.definition.has_rubygems_remotes?
93
- Bundler.ui.warn <<-WARN, :wrap => true
94
- Your Gemfile has no gem server sources. If you need gems that are \
95
- not already on your machine, add a line like this to your Gemfile:
96
- source 'https://rubygems.org'
97
- WARN
98
- end
99
- raise e
100
- rescue Gem::InvalidSpecificationException => e
88
+ rescue Gem::InvalidSpecificationException
101
89
  Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed."
102
- raise e
90
+ raise
103
91
  end
104
92
 
105
93
  private
106
94
 
107
95
  def warn_if_root
108
- return if Bundler.settings[:silence_root_warning] || Bundler::WINDOWS || !Process.uid.zero?
96
+ return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero?
109
97
  Bundler.ui.warn "Don't run Bundler as root. Bundler can ask for sudo " \
110
98
  "if it is needed, and installing your bundle as root will break this " \
111
99
  "application for all non-root users on this machine.", :wrap => true
@@ -147,42 +135,23 @@ module Bundler
147
135
  end
148
136
 
149
137
  def normalize_groups
150
- options[:with] &&= options[:with].join(":").tr(" ", ":").split(":")
151
- options[:without] &&= options[:without].join(":").tr(" ", ":").split(":")
152
-
153
138
  check_for_group_conflicts_in_cli_options
154
139
 
155
- Bundler.settings.set_command_option :with, nil if options[:with] == []
156
- Bundler.settings.set_command_option :without, nil if options[:without] == []
157
-
158
- with = options.fetch(:with, [])
159
- with |= Bundler.settings[:with].map(&:to_s)
160
- with -= options[:without] if options[:without]
161
-
162
- without = options.fetch(:without, [])
163
- without |= Bundler.settings[:without].map(&:to_s)
164
- without -= options[:with] if options[:with]
165
-
166
- options[:with] = with
167
- options[:without] = without
168
-
169
- unless Bundler.settings[:without] == options[:without] && Bundler.settings[:with] == options[:with]
170
- # need to nil them out first to get around validation for backwards compatibility
171
- Bundler.settings.set_command_option :without, nil
172
- Bundler.settings.set_command_option :with, nil
173
- Bundler.settings.set_command_option :without, options[:without] - options[:with]
174
- Bundler.settings.set_command_option :with, options[:with]
175
- end
140
+ # need to nil them out first to get around validation for backwards compatibility
141
+ Bundler.settings.set_command_option :without, nil
142
+ Bundler.settings.set_command_option :with, nil
143
+ Bundler.settings.set_command_option :without, options[:without]
144
+ Bundler.settings.set_command_option :with, options[:with]
176
145
  end
177
146
 
178
147
  def normalize_settings
179
148
  Bundler.settings.set_command_option :path, nil if options[:system]
180
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
181
- Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil?
182
- end
183
149
  Bundler.settings.set_command_option_if_given :path, options[:path]
184
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
185
- Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
150
+
151
+ if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
152
+ Bundler.settings.temporary(:path_relative_to_cwd => false) do
153
+ Bundler.settings.set_command_option :path, "bundle"
154
+ end
186
155
  end
187
156
 
188
157
  bin_option = options["binstubs"]
@@ -199,7 +168,7 @@ module Bundler
199
168
 
200
169
  Bundler.settings.set_command_option_if_given :clean, options["clean"]
201
170
 
202
- normalize_groups
171
+ normalize_groups if options[:without] || options[:with]
203
172
 
204
173
  options[:force] = options[:redownload]
205
174
  end
@@ -20,9 +20,10 @@ module Bundler
20
20
 
21
21
  Hopefully the troubleshooting steps above resolved your problem! If things
22
22
  still aren't working the way you expect them to, please let us know so
23
- that we can diagnose and help fix the problem you're having. Please
24
- view the Filing Issues guide for more information:
25
- https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/ISSUES.md
23
+ that we can diagnose and help fix the problem you're having, by filling
24
+ in the new issue form located at
25
+ https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
26
+ and copy and pasting the information below.
26
27
 
27
28
  EOS
28
29
 
@@ -16,7 +16,13 @@ module Bundler
16
16
  specs = if @only_group.any? || @without_group.any?
17
17
  filtered_specs_by_groups
18
18
  else
19
- Bundler.load.specs
19
+ begin
20
+ Bundler.load.specs
21
+ rescue GemNotFound => e
22
+ Bundler.ui.error e.message
23
+ Bundler.ui.warn "Install missing gems with `bundle install`."
24
+ exit 1
25
+ end
20
26
  end.reject {|s| s.name == "bundler" }.sort_by(&:name)
21
27
 
22
28
  return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
@@ -21,9 +21,13 @@ module Bundler
21
21
  Bundler::Fetcher.disable_endpoint = options["full-index"]
22
22
 
23
23
  update = options[:update]
24
+ conservative = options[:conservative]
25
+
24
26
  if update.is_a?(Array) # unlocking specific gems
25
27
  Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
26
- update = { :gems => update, :lock_shared_dependencies => options[:conservative] }
28
+ update = { :gems => update, :conservative => conservative }
29
+ elsif update
30
+ update = { :conservative => conservative } if conservative
27
31
  end
28
32
  definition = Bundler.definition(update)
29
33
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class CLI::Open
7
5
  attr_reader :options, :name
@@ -19,6 +17,7 @@ module Bundler
19
17
  else
20
18
  path = spec.full_gem_path
21
19
  Dir.chdir(path) do
20
+ require "shellwords"
22
21
  command = Shellwords.split(editor) + [path]
23
22
  Bundler.with_original_env do
24
23
  system(*command)
@@ -46,7 +46,7 @@ module Bundler
46
46
 
47
47
  Bundler::CLI::Common.configure_gem_version_promoter(
48
48
  Bundler.definition,
49
- options
49
+ options.merge(:strict => @strict)
50
50
  )
51
51
 
52
52
  definition_resolution = proc do
@@ -72,7 +72,7 @@ module Bundler
72
72
  gemfile_specs + dependency_specs
73
73
  end
74
74
 
75
- specs.sort_by(&:name).each do |current_spec|
75
+ specs.sort_by(&:name).uniq(&:name).each do |current_spec|
76
76
  next unless gems.empty? || gems.include?(current_spec.name)
77
77
 
78
78
  active_spec = retrieve_active_spec(definition, current_spec)
@@ -129,6 +129,12 @@ module Bundler
129
129
 
130
130
  private
131
131
 
132
+ def loaded_from_for(spec)
133
+ return unless spec.respond_to?(:loaded_from)
134
+
135
+ spec.loaded_from
136
+ end
137
+
132
138
  def groups_text(group_text, groups)
133
139
  "#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\""
134
140
  end
@@ -146,17 +152,16 @@ module Bundler
146
152
  end
147
153
 
148
154
  def retrieve_active_spec(definition, current_spec)
149
- if strict
150
- active_spec = definition.find_resolved_spec(current_spec)
151
- else
152
- active_specs = definition.find_indexed_specs(current_spec)
153
- if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
154
- active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
155
- end
156
- active_spec = active_specs.last
157
- end
155
+ active_spec = definition.resolve.find_by_name_and_platform(current_spec.name, current_spec.platform)
156
+ return unless active_spec
157
+
158
+ return active_spec if strict
158
159
 
159
- active_spec
160
+ active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
161
+ if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
162
+ active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
163
+ end
164
+ active_specs.last
160
165
  end
161
166
 
162
167
  def print_gems(gems_list)
@@ -185,7 +190,10 @@ module Bundler
185
190
 
186
191
  def print_gem(current_spec, active_spec, dependency, groups)
187
192
  spec_version = "#{active_spec.version}#{active_spec.git_version}"
188
- spec_version += " (from #{active_spec.loaded_from})" if Bundler.ui.debug? && active_spec.loaded_from
193
+ if Bundler.ui.debug?
194
+ loaded_from = loaded_from_for(active_spec)
195
+ spec_version += " (from #{loaded_from})" if loaded_from
196
+ end
189
197
  current_version = "#{current_spec.version}#{current_spec.git_version}"
190
198
 
191
199
  if dependency && dependency.specific?
@@ -212,7 +220,7 @@ module Bundler
212
220
  dependency = dependency.requirement if dependency
213
221
 
214
222
  ret_val = [active_spec.name, current_version, spec_version, dependency.to_s, groups.to_s]
215
- ret_val << active_spec.loaded_from.to_s if Bundler.ui.debug?
223
+ ret_val << loaded_from_for(active_spec).to_s if Bundler.ui.debug?
216
224
  ret_val
217
225
  end
218
226
 
@@ -9,7 +9,7 @@ module Bundler
9
9
 
10
10
  def run
11
11
  platforms, ruby_version = Bundler.ui.silence do
12
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version
12
+ locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
13
13
  gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
14
14
  [Bundler.definition.platforms.map {|p| "* #{p}" },
15
15
  locked_ruby_version || gemfile_ruby_version]
@@ -23,7 +23,7 @@ module Bundler
23
23
  output << "No ruby version specified"
24
24
  end
25
25
  else
26
- output << "Your platform is: #{RUBY_PLATFORM}"
26
+ output << "Your platform is: #{Gem::Platform.local}"
27
27
  output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
28
28
 
29
29
  if ruby_version
@@ -11,8 +11,7 @@ module Bundler
11
11
  raise InvalidOption, "Please specify gems to remove." if @gems.empty?
12
12
 
13
13
  Injector.remove(@gems, {})
14
-
15
- Installer.install(Bundler.root, Bundler.definition) if @options["install"]
14
+ Installer.install(Bundler.root, Bundler.definition)
16
15
  end
17
16
  end
18
17
  end
@@ -18,7 +18,7 @@ module Bundler
18
18
 
19
19
  if gem_name
20
20
  if gem_name == "bundler"
21
- path = File.expand_path("../../../..", __FILE__)
21
+ path = File.expand_path("../../..", __dir__)
22
22
  else
23
23
  spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match)
24
24
  return unless spec
@@ -9,14 +9,18 @@ module Bundler
9
9
  end
10
10
 
11
11
  def run
12
- Bundler.ui.level = "error" if options[:quiet]
12
+ Bundler.ui.level = "warn" if options[:quiet]
13
+
14
+ update_bundler = options[:bundler]
15
+
16
+ Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler
13
17
 
14
18
  Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
15
19
 
16
20
  sources = Array(options[:source])
17
21
  groups = Array(options[:group]).map(&:to_sym)
18
22
 
19
- full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
23
+ full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !update_bundler
20
24
 
21
25
  if full_update && !options[:all]
22
26
  if Bundler.feature_flag.update_requires_all_flag?
@@ -27,9 +31,14 @@ module Bundler
27
31
  raise InvalidOption, "Cannot specify --all along with specific options."
28
32
  end
29
33
 
34
+ conservative = options[:conservative]
35
+
30
36
  if full_update
31
- # We're doing a full update
32
- Bundler.definition(true)
37
+ if conservative
38
+ Bundler.definition(:conservative => conservative)
39
+ else
40
+ Bundler.definition(true)
41
+ end
33
42
  else
34
43
  unless Bundler.default_lockfile.exist?
35
44
  raise GemfileLockNotFound, "This Bundle hasn't been installed yet. " \
@@ -43,8 +52,8 @@ module Bundler
43
52
  end
44
53
 
45
54
  Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
46
- :lock_shared_dependencies => options[:conservative],
47
- :bundler => options[:bundler])
55
+ :conservative => conservative,
56
+ :bundler => update_bundler)
48
57
  end
49
58
 
50
59
  Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
@@ -61,7 +70,7 @@ module Bundler
61
70
 
62
71
  if locked_gems = Bundler.definition.locked_gems
63
72
  previous_locked_info = locked_gems.specs.reduce({}) do |h, s|
64
- h[s.name] = { :spec => s, :version => s.version, :source => s.source.to_s }
73
+ h[s.name] = { :spec => s, :version => s.version, :source => s.source.identifier }
65
74
  h
66
75
  end
67
76
  end
@@ -90,7 +99,7 @@ module Bundler
90
99
  end
91
100
 
92
101
  locked_source = locked_info[:source]
93
- new_source = new_spec.source.to_s
102
+ new_source = new_spec.source.identifier
94
103
  next if locked_source != new_source
95
104
 
96
105
  new_version = new_spec.version
data/lib/bundler/cli.rb CHANGED
@@ -14,6 +14,7 @@ module Bundler
14
14
  COMMAND_ALIASES = {
15
15
  "check" => "c",
16
16
  "install" => "i",
17
+ "plugin" => "",
17
18
  "list" => "ls",
18
19
  "exec" => ["e", "ex", "exe"],
19
20
  "cache" => ["package", "pack"],
@@ -60,6 +61,8 @@ module Bundler
60
61
  Bundler.reset_settings_and_root!
61
62
  end
62
63
 
64
+ Bundler.self_manager.restart_with_locked_bundler_if_needed
65
+
63
66
  Bundler.settings.set_command_option_if_given :retry, options[:retry]
64
67
 
65
68
  current_cmd = args.last[:current_command].name
@@ -72,14 +75,6 @@ module Bundler
72
75
  Bundler.ui = UI::Shell.new(options)
73
76
  Bundler.ui.level = "debug" if options["verbose"]
74
77
  unprinted_warnings.each {|w| Bundler.ui.warn(w) }
75
-
76
- if ENV["RUBYGEMS_GEMDEPS"] && !ENV["RUBYGEMS_GEMDEPS"].empty?
77
- Bundler.ui.warn(
78
- "The RUBYGEMS_GEMDEPS environment variable is set. This enables RubyGems' " \
79
- "experimental Gemfile mode, which may conflict with Bundler and cause unexpected errors. " \
80
- "To remove this warning, unset RUBYGEMS_GEMDEPS.", :wrap => true
81
- )
82
- end
83
78
  end
84
79
 
85
80
  check_unknown_options!(:except => [:config, :exec])
@@ -191,6 +186,7 @@ module Bundler
191
186
  method_option "install", :type => :boolean, :banner =>
192
187
  "Runs 'bundle install' after removing the gems from the Gemfile"
193
188
  def remove(*gems)
189
+ SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install")
194
190
  require_relative "cli/remove"
195
191
  Remove.new(gems, options).run
196
192
  end
@@ -222,6 +218,8 @@ module Bundler
222
218
  "Specify the number of jobs to run in parallel"
223
219
  method_option "local", :type => :boolean, :banner =>
224
220
  "Do not attempt to fetch gems remotely and use the gem cache instead"
221
+ method_option "prefer-local", :type => :boolean, :banner =>
222
+ "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
225
223
  method_option "no-cache", :type => :boolean, :banner =>
226
224
  "Don't update the existing gem cache."
227
225
  method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
@@ -240,7 +238,7 @@ module Bundler
240
238
  "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
241
239
  method_option "trust-policy", :alias => "P", :type => :string, :banner =>
242
240
  "Gem trust policy (like gem install -P). Must be one of " +
243
- Bundler.rubygems.security_policy_keys.join("|")
241
+ Bundler.rubygems.security_policy_keys.join("|")
244
242
  method_option "without", :type => :array, :banner =>
245
243
  "Exclude gems that are part of the specified named group."
246
244
  method_option "with", :type => :array, :banner =>
@@ -308,39 +306,19 @@ module Bundler
308
306
  end
309
307
  end
310
308
 
311
- unless Bundler.feature_flag.bundler_3_mode?
312
- desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
313
- long_desc <<-D
314
- Show lists the names and versions of all gems that are required by your Gemfile.
315
- Calling show with [GEM] will list the exact location of that gem on your machine.
316
- D
317
- method_option "paths", :type => :boolean,
318
- :banner => "List the paths of all gems that are required by your Gemfile."
319
- method_option "outdated", :type => :boolean,
320
- :banner => "Show verbose output including whether gems are outdated."
321
- def show(gem_name = nil)
322
- if ARGV[0] == "show"
323
- rest = ARGV[1..-1]
324
-
325
- if flag = rest.find{|arg| ["--verbose", "--outdated"].include?(arg) }
326
- Bundler::SharedHelpers.major_deprecation(2, "the `#{flag}` flag to `bundle show` was undocumented and will be removed without replacement")
327
- else
328
- new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list"
329
-
330
- new_arguments = rest.map do |arg|
331
- next arg if arg != "--paths"
332
- next "--path" if new_command == "info"
333
- end
334
-
335
- old_argv = ARGV.join(" ")
336
- new_argv = [new_command, *new_arguments.compact].join(" ")
337
-
338
- Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
339
- end
340
- end
341
- require_relative "cli/show"
342
- Show.new(options, gem_name).run
343
- end
309
+ desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
310
+ long_desc <<-D
311
+ Show lists the names and versions of all gems that are required by your Gemfile.
312
+ Calling show with [GEM] will list the exact location of that gem on your machine.
313
+ D
314
+ method_option "paths", :type => :boolean,
315
+ :banner => "List the paths of all gems that are required by your Gemfile."
316
+ method_option "outdated", :type => :boolean,
317
+ :banner => "Show verbose output including whether gems are outdated."
318
+ def show(gem_name = nil)
319
+ SharedHelpers.major_deprecation(2, "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") if ARGV.include?("--outdated")
320
+ require_relative "cli/show"
321
+ Show.new(options, gem_name).run
344
322
  end
345
323
 
346
324
  desc "list", "List all gems in the bundle"
@@ -357,6 +335,7 @@ module Bundler
357
335
 
358
336
  desc "info GEM [OPTIONS]", "Show information for the given gem"
359
337
  method_option "path", :type => :boolean, :banner => "Print full path to gem"
338
+ method_option "version", :type => :boolean, :banner => "Print gem version"
360
339
  def info(gem_name)
361
340
  require_relative "cli/info"
362
341
  Info.new(options, gem_name).run
@@ -392,8 +371,12 @@ module Bundler
392
371
  method_option "version", :aliases => "-v", :type => :string
393
372
  method_option "group", :aliases => "-g", :type => :string
394
373
  method_option "source", :aliases => "-s", :type => :string
374
+ method_option "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
375
+ method_option "path", :type => :string
395
376
  method_option "git", :type => :string
377
+ method_option "github", :type => :string
396
378
  method_option "branch", :type => :string
379
+ method_option "ref", :type => :string
397
380
  method_option "skip-install", :type => :boolean, :banner =>
398
381
  "Adds gem to the Gemfile but does not install it"
399
382
  method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
@@ -411,7 +394,7 @@ module Bundler
411
394
  are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
412
395
 
413
396
  For more information on patch level options (--major, --minor, --patch,
414
- --update-strict) see documentation on the same options on the update command.
397
+ --strict) see documentation on the same options on the update command.
415
398
  D
416
399
  method_option "group", :type => :string, :banner => "List gems from a specific group"
417
400
  method_option "groups", :type => :boolean, :banner => "List gems organized by groups"
@@ -419,10 +402,9 @@ module Bundler
419
402
  "Do not attempt to fetch gems remotely and use the gem cache instead"
420
403
  method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
421
404
  method_option "source", :type => :array, :banner => "Check against a specific source"
422
- strict_is_update = Bundler.feature_flag.forget_cli_options?
423
- method_option "filter-strict", :type => :boolean, :aliases => strict_is_update ? [] : %w[--strict], :banner =>
405
+ method_option "filter-strict", :type => :boolean, :aliases => "--strict", :banner =>
424
406
  "Only list newer versions allowed by your Gemfile requirements"
425
- method_option "update-strict", :type => :boolean, :aliases => strict_is_update ? %w[--strict] : [], :banner =>
407
+ method_option "update-strict", :type => :boolean, :banner =>
426
408
  "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
427
409
  method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
428
410
  method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
@@ -475,6 +457,12 @@ module Bundler
475
457
  "do in future versions. Instead please use `bundle config set cache_all true`, " \
476
458
  "and stop using this flag" if ARGV.include?("--all")
477
459
 
460
+ SharedHelpers.major_deprecation 2,
461
+ "The `--path` flag is deprecated because its semantics are unclear. " \
462
+ "Use `bundle config cache_path` to configure the path of your cache of gems, " \
463
+ "and `bundle config path` to configure the path where your gems are installed, " \
464
+ "and stop using this flag" if ARGV.include?("--path")
465
+
478
466
  require_relative "cli/cache"
479
467
  Cache.new(options).run
480
468
  end
@@ -482,7 +470,7 @@ module Bundler
482
470
  map aliases_for("cache")
483
471
 
484
472
  desc "exec [OPTIONS]", "Run the command in context of the bundle"
485
- method_option :keep_file_descriptors, :type => :boolean, :default => false
473
+ method_option :keep_file_descriptors, :type => :boolean, :default => true
486
474
  method_option :gemfile, :type => :string, :required => false
487
475
  long_desc <<-D
488
476
  Exec runs a command, providing it access to the gems in the bundle. While using
@@ -490,6 +478,10 @@ module Bundler
490
478
  into the system wide RubyGems repository.
491
479
  D
492
480
  def exec(*args)
481
+ if ARGV.include?("--no-keep-file-descriptors")
482
+ SharedHelpers.major_deprecation(2, "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to")
483
+ end
484
+
493
485
  require_relative "cli/exec"
494
486
  Exec.new(options, args).run
495
487
  end
@@ -504,8 +496,8 @@ module Bundler
504
496
  By default, setting a configuration value sets it for all projects
505
497
  on the machine.
506
498
 
507
- If a global setting is superceded by local configuration, this command
508
- will show the current value, as well as any superceded values and
499
+ If a global setting is superseded by local configuration, this command
500
+ will show the current value, as well as any superseded values and
509
501
  where they were specified.
510
502
  D
511
503
  require_relative "cli/config"
@@ -525,7 +517,7 @@ module Bundler
525
517
  end
526
518
  end
527
519
 
528
- desc "version", "Prints the bundler's version information"
520
+ desc "version", "Prints Bundler version information"
529
521
  def version
530
522
  cli_help = current_command.name == "cli_help"
531
523
  if cli_help || ARGV.include?("version")
@@ -568,7 +560,7 @@ module Bundler
568
560
  method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
569
561
  method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
570
562
  def viz
571
- SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
563
+ SharedHelpers.major_deprecation 2, "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
572
564
  require_relative "cli/viz"
573
565
  Viz.new(options.dup).run
574
566
  end
@@ -591,6 +583,9 @@ module Bundler
591
583
  :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
592
584
  method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
593
585
  :desc => "Generate CI configuration, either GitHub Actions, Travis CI, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|travis|gitlab|circle)`"
586
+ method_option :linter, :type => :string, :lazy_default => Bundler.settings["gem.linter"] || "",
587
+ :desc => "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
588
+ method_option :github_username, :type => :string, :default => Bundler.settings["gem.github_username"], :banner => "Set your username on GitHub", :desc => "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
594
589
 
595
590
  def gem(name)
596
591
  end
@@ -618,14 +613,14 @@ module Bundler
618
613
  private :gem
619
614
 
620
615
  def self.source_root
621
- File.expand_path(File.join(File.dirname(__FILE__), "templates"))
616
+ File.expand_path("templates", __dir__)
622
617
  end
623
618
 
624
619
  desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true
625
620
  method_option "dry-run", :type => :boolean, :default => false, :banner =>
626
621
  "Only print out changes, do not clean gems"
627
622
  method_option "force", :type => :boolean, :default => false, :banner =>
628
- "Forces clean even if --path is not set"
623
+ "Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application."
629
624
  def clean
630
625
  require_relative "cli/clean"
631
626
  Clean.new(options.dup).run
@@ -816,17 +811,10 @@ module Bundler
816
811
 
817
812
  current = Gem::Version.new(VERSION)
818
813
  return if current >= latest
819
- latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max
820
-
821
- installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`"
822
- if latest_installed && latest_installed > current
823
- suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`"
824
- suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest
825
- else
826
- suggestion = installation
827
- end
828
814
 
829
- Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
815
+ Bundler.ui.warn \
816
+ "The latest bundler is #{latest}, but you are currently running #{current}.\n" \
817
+ "To update to the most recent version, run `bundle update --bundler`"
830
818
  rescue RuntimeError
831
819
  nil
832
820
  end
@@ -76,15 +76,6 @@ module Bundler
76
76
  end
77
77
  end
78
78
 
79
- def specific_dependency(name, version, platform)
80
- pattern = [version, platform].compact.join("-")
81
- return nil if pattern.empty?
82
-
83
- gem_lines = info_path(name).read
84
- gem_line = gem_lines[/^#{Regexp.escape(pattern)}\b.*/, 0]
85
- gem_line ? parse_gem(gem_line) : nil
86
- end
87
-
88
79
  private
89
80
 
90
81
  def lines(path)