bundler 1.15.2 → 1.17.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (286) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +302 -0
  3. data/README.md +17 -8
  4. data/bundler.gemspec +25 -9
  5. data/exe/bundle +1 -1
  6. data/exe/bundle_ruby +4 -3
  7. data/lib/bundler/build_metadata.rb +53 -0
  8. data/lib/bundler/capistrano.rb +5 -0
  9. data/lib/bundler/cli/add.rb +15 -6
  10. data/lib/bundler/cli/binstubs.rb +17 -9
  11. data/lib/bundler/cli/cache.rb +5 -4
  12. data/lib/bundler/cli/check.rb +3 -5
  13. data/lib/bundler/cli/clean.rb +5 -6
  14. data/lib/bundler/cli/common.rb +11 -2
  15. data/lib/bundler/cli/config.rb +2 -1
  16. data/lib/bundler/cli/console.rb +2 -1
  17. data/lib/bundler/cli/doctor.rb +48 -1
  18. data/lib/bundler/cli/exec.rb +6 -5
  19. data/lib/bundler/cli/gem.rb +13 -8
  20. data/lib/bundler/cli/info.rb +0 -1
  21. data/lib/bundler/cli/init.rb +18 -6
  22. data/lib/bundler/cli/inject.rb +1 -0
  23. data/lib/bundler/cli/install.rb +64 -61
  24. data/lib/bundler/cli/issue.rb +1 -1
  25. data/lib/bundler/cli/list.rb +58 -0
  26. data/lib/bundler/cli/lock.rb +0 -1
  27. data/lib/bundler/cli/open.rb +2 -2
  28. data/lib/bundler/cli/outdated.rb +20 -9
  29. data/lib/bundler/cli/package.rb +9 -6
  30. data/lib/bundler/cli/platform.rb +1 -0
  31. data/lib/bundler/cli/plugin.rb +1 -0
  32. data/lib/bundler/cli/pristine.rb +20 -6
  33. data/lib/bundler/cli/remove.rb +18 -0
  34. data/lib/bundler/cli/show.rb +0 -1
  35. data/lib/bundler/cli/update.rb +35 -7
  36. data/lib/bundler/cli/viz.rb +1 -0
  37. data/lib/bundler/cli.rb +227 -89
  38. data/lib/bundler/compact_index_client/cache.rb +1 -2
  39. data/lib/bundler/compact_index_client/updater.rb +14 -4
  40. data/lib/bundler/compact_index_client.rb +1 -0
  41. data/lib/bundler/compatibility_guard.rb +14 -0
  42. data/lib/bundler/constants.rb +1 -0
  43. data/lib/bundler/current_ruby.rb +13 -5
  44. data/lib/bundler/definition.rb +192 -139
  45. data/lib/bundler/dep_proxy.rb +3 -1
  46. data/lib/bundler/dependency.rb +9 -9
  47. data/lib/bundler/deployment.rb +1 -1
  48. data/lib/bundler/deprecate.rb +15 -3
  49. data/lib/bundler/dsl.rb +115 -64
  50. data/lib/bundler/endpoint_specification.rb +10 -1
  51. data/lib/bundler/env.rb +90 -29
  52. data/lib/bundler/environment_preserver.rb +27 -6
  53. data/lib/bundler/errors.rb +1 -0
  54. data/lib/bundler/feature_flag.rb +46 -4
  55. data/lib/bundler/fetcher/base.rb +1 -0
  56. data/lib/bundler/fetcher/compact_index.rb +2 -11
  57. data/lib/bundler/fetcher/dependency.rb +2 -1
  58. data/lib/bundler/fetcher/downloader.rb +11 -5
  59. data/lib/bundler/fetcher/index.rb +3 -2
  60. data/lib/bundler/fetcher.rb +18 -11
  61. data/lib/bundler/friendly_errors.rb +6 -1
  62. data/lib/bundler/gem_helper.rb +19 -10
  63. data/lib/bundler/gem_helpers.rb +1 -0
  64. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  65. data/lib/bundler/gem_tasks.rb +1 -0
  66. data/lib/bundler/gem_version_promoter.rb +17 -2
  67. data/lib/bundler/gemdeps.rb +1 -0
  68. data/lib/bundler/graph.rb +1 -0
  69. data/lib/bundler/index.rb +8 -8
  70. data/lib/bundler/injector.rb +192 -30
  71. data/lib/bundler/inline.rb +5 -7
  72. data/lib/bundler/installer/gem_installer.rb +11 -2
  73. data/lib/bundler/installer/parallel_installer.rb +78 -42
  74. data/lib/bundler/installer/standalone.rb +1 -0
  75. data/lib/bundler/installer.rb +138 -53
  76. data/lib/bundler/lazy_specification.rb +3 -2
  77. data/lib/bundler/lockfile_generator.rb +95 -0
  78. data/lib/bundler/lockfile_parser.rb +10 -4
  79. data/lib/bundler/match_platform.rb +1 -0
  80. data/lib/bundler/mirror.rb +8 -5
  81. data/lib/bundler/plugin/api/source.rb +9 -2
  82. data/lib/bundler/plugin/events.rb +61 -0
  83. data/lib/bundler/plugin/index.rb +7 -2
  84. data/lib/bundler/plugin/installer.rb +7 -6
  85. data/lib/bundler/plugin/source_list.rb +7 -8
  86. data/lib/bundler/plugin.rb +13 -5
  87. data/lib/bundler/process_lock.rb +24 -0
  88. data/lib/bundler/psyched_yaml.rb +10 -0
  89. data/lib/bundler/remote_specification.rb +1 -0
  90. data/lib/bundler/resolver/spec_group.rb +106 -0
  91. data/lib/bundler/resolver.rb +158 -195
  92. data/lib/bundler/retry.rb +1 -0
  93. data/lib/bundler/ruby_dsl.rb +1 -0
  94. data/lib/bundler/ruby_version.rb +2 -1
  95. data/lib/bundler/rubygems_ext.rb +5 -4
  96. data/lib/bundler/rubygems_gem_installer.rb +31 -1
  97. data/lib/bundler/rubygems_integration.rb +71 -32
  98. data/lib/bundler/runtime.rb +11 -9
  99. data/lib/bundler/settings/validator.rb +102 -0
  100. data/lib/bundler/settings.rb +200 -77
  101. data/lib/bundler/setup.rb +1 -0
  102. data/lib/bundler/shared_helpers.rb +131 -26
  103. data/lib/bundler/similarity_detector.rb +1 -0
  104. data/lib/bundler/source/gemspec.rb +1 -0
  105. data/lib/bundler/source/git/git_proxy.rb +21 -11
  106. data/lib/bundler/source/git.rb +24 -19
  107. data/lib/bundler/source/metadata.rb +62 -0
  108. data/lib/bundler/source/path/installer.rb +2 -0
  109. data/lib/bundler/source/path.rb +8 -8
  110. data/lib/bundler/source/rubygems/remote.rb +8 -2
  111. data/lib/bundler/source/rubygems.rb +161 -84
  112. data/lib/bundler/source.rb +36 -0
  113. data/lib/bundler/source_list.rb +75 -15
  114. data/lib/bundler/spec_set.rb +10 -5
  115. data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  116. data/lib/bundler/stub_specification.rb +1 -0
  117. data/lib/bundler/templates/.document +1 -0
  118. data/lib/bundler/templates/Executable +12 -0
  119. data/lib/bundler/templates/Executable.bundler +105 -0
  120. data/lib/bundler/templates/Gemfile +1 -0
  121. data/lib/bundler/templates/gems.rb +8 -0
  122. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  123. data/lib/bundler/templates/newgem/gitignore.tt +0 -1
  124. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  125. data/lib/bundler/templates/newgem/newgem.gemspec.tt +12 -3
  126. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  127. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  128. data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
  129. data/lib/bundler/ui/rg_proxy.rb +1 -0
  130. data/lib/bundler/ui/shell.rb +17 -4
  131. data/lib/bundler/ui/silent.rb +1 -0
  132. data/lib/bundler/ui.rb +1 -0
  133. data/lib/bundler/uri_credentials_filter.rb +1 -0
  134. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  135. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  136. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  137. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  138. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  139. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -0
  140. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  141. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  142. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  143. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  144. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  145. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  146. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +15 -4
  147. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -2
  148. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
  149. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  150. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  151. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  152. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +491 -148
  153. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  154. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  155. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  156. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  157. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -0
  158. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -0
  159. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +9 -1
  160. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +45 -8
  161. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +9 -3
  162. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -3
  163. data/lib/bundler/vendor/thor/lib/thor/base.rb +27 -4
  164. data/lib/bundler/vendor/thor/lib/thor/command.rb +9 -7
  165. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +12 -0
  166. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  167. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  168. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +5 -5
  169. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +6 -5
  170. data/lib/bundler/vendor/thor/lib/thor/runner.rb +6 -4
  171. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -9
  172. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  173. data/lib/bundler/vendor/thor/lib/thor.rb +25 -8
  174. data/lib/bundler/vendored_fileutils.rb +9 -0
  175. data/lib/bundler/vendored_molinillo.rb +1 -0
  176. data/lib/bundler/vendored_persistent.rb +35 -0
  177. data/lib/bundler/vendored_thor.rb +1 -0
  178. data/lib/bundler/version.rb +6 -2
  179. data/lib/bundler/version_ranges.rb +1 -0
  180. data/lib/bundler/vlad.rb +5 -0
  181. data/lib/bundler/worker.rb +1 -0
  182. data/lib/bundler/yaml_serializer.rb +3 -3
  183. data/lib/bundler.rb +86 -52
  184. data/man/bundle-add.1 +18 -3
  185. data/man/bundle-add.1.txt +26 -14
  186. data/man/bundle-add.ronn +13 -2
  187. data/man/bundle-binstubs.1 +11 -1
  188. data/man/bundle-binstubs.1.txt +33 -18
  189. data/man/bundle-binstubs.ronn +15 -1
  190. data/man/bundle-check.1 +4 -4
  191. data/man/bundle-check.1.txt +15 -14
  192. data/man/bundle-check.ronn +3 -3
  193. data/man/bundle-clean.1 +1 -1
  194. data/man/bundle-clean.1.txt +10 -10
  195. data/man/bundle-config.1 +129 -29
  196. data/man/bundle-config.1.txt +285 -174
  197. data/man/bundle-config.ronn +167 -88
  198. data/man/bundle-doctor.1 +44 -0
  199. data/man/bundle-doctor.1.txt +44 -0
  200. data/man/bundle-doctor.ronn +33 -0
  201. data/man/bundle-exec.1 +6 -3
  202. data/man/bundle-exec.1.txt +78 -71
  203. data/man/bundle-exec.ronn +10 -3
  204. data/man/bundle-gem.1 +3 -3
  205. data/man/bundle-gem.1.txt +40 -39
  206. data/man/bundle-gem.ronn +2 -1
  207. data/man/bundle-info.1 +1 -1
  208. data/man/bundle-info.1.txt +8 -8
  209. data/man/bundle-init.1 +9 -4
  210. data/man/bundle-init.1.txt +23 -13
  211. data/man/bundle-init.ronn +15 -4
  212. data/man/bundle-inject.1 +4 -4
  213. data/man/bundle-inject.1.txt +10 -10
  214. data/man/bundle-inject.ronn +3 -3
  215. data/man/bundle-install.1 +31 -28
  216. data/man/bundle-install.1.txt +205 -194
  217. data/man/bundle-install.ronn +44 -35
  218. data/man/bundle-list.1 +50 -0
  219. data/man/bundle-list.1.txt +43 -0
  220. data/man/bundle-list.ronn +33 -0
  221. data/man/bundle-lock.1 +1 -1
  222. data/man/bundle-lock.1.txt +47 -47
  223. data/man/bundle-lock.ronn +1 -1
  224. data/man/bundle-open.1 +1 -1
  225. data/man/bundle-open.1.txt +7 -7
  226. data/man/bundle-outdated.1 +7 -3
  227. data/man/bundle-outdated.1.txt +40 -36
  228. data/man/bundle-outdated.ronn +6 -2
  229. data/man/bundle-package.1 +6 -3
  230. data/man/bundle-package.1.txt +44 -39
  231. data/man/bundle-package.ronn +7 -2
  232. data/man/bundle-platform.1 +1 -1
  233. data/man/bundle-platform.1.txt +13 -13
  234. data/man/bundle-pristine.1 +21 -3
  235. data/man/bundle-pristine.1.txt +33 -10
  236. data/man/bundle-pristine.ronn +24 -3
  237. data/man/bundle-remove.1 +31 -0
  238. data/man/bundle-remove.1.txt +34 -0
  239. data/man/bundle-remove.ronn +23 -0
  240. data/man/bundle-show.1 +3 -3
  241. data/man/bundle-show.1.txt +14 -12
  242. data/man/bundle-show.ronn +3 -2
  243. data/man/bundle-update.1 +13 -9
  244. data/man/bundle-update.1.txt +133 -130
  245. data/man/bundle-update.ronn +21 -17
  246. data/man/bundle-viz.1 +7 -7
  247. data/man/bundle-viz.1.txt +17 -15
  248. data/man/bundle-viz.ronn +6 -6
  249. data/man/bundle.1 +31 -23
  250. data/man/bundle.1.txt +63 -57
  251. data/man/bundle.ronn +35 -29
  252. data/man/gemfile.5 +44 -8
  253. data/man/gemfile.5.ronn +54 -8
  254. data/man/gemfile.5.txt +218 -165
  255. data/man/index.txt +25 -15
  256. metadata +36 -36
  257. data/.codeclimate.yml +0 -25
  258. data/.gitignore +0 -18
  259. data/.rspec +0 -3
  260. data/.rubocop.yml +0 -131
  261. data/.rubocop_todo.yml +0 -418
  262. data/.travis.yml +0 -122
  263. data/CODE_OF_CONDUCT.md +0 -42
  264. data/CONTRIBUTING.md +0 -17
  265. data/Rakefile +0 -338
  266. data/bin/rake +0 -19
  267. data/bin/rspec +0 -15
  268. data/bin/rubocop +0 -17
  269. data/bin/with_rubygems +0 -39
  270. data/doc/README.md +0 -30
  271. data/doc/TROUBLESHOOTING.md +0 -64
  272. data/doc/contributing/BUG_TRIAGE.md +0 -36
  273. data/doc/contributing/COMMUNITY.md +0 -13
  274. data/doc/contributing/GETTING_HELP.md +0 -11
  275. data/doc/contributing/HOW_YOU_CAN_HELP.md +0 -27
  276. data/doc/contributing/ISSUES.md +0 -51
  277. data/doc/contributing/README.md +0 -38
  278. data/doc/development/NEW_FEATURES.md +0 -10
  279. data/doc/development/PULL_REQUESTS.md +0 -40
  280. data/doc/development/README.md +0 -19
  281. data/doc/development/RELEASING.md +0 -9
  282. data/doc/development/SETUP.md +0 -27
  283. data/doc/documentation/README.md +0 -29
  284. data/doc/documentation/VISION.md +0 -26
  285. data/doc/documentation/WRITING.md +0 -54
  286. data/task/release.rake +0 -116
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler/lockfile_parser"
3
- require "digest/sha1"
4
4
  require "set"
5
5
 
6
6
  module Bundler
@@ -9,12 +9,13 @@ module Bundler
9
9
 
10
10
  attr_reader(
11
11
  :dependencies,
12
- :gem_version_promoter,
13
12
  :locked_deps,
14
13
  :locked_gems,
15
14
  :platforms,
16
15
  :requires,
17
- :ruby_version
16
+ :ruby_version,
17
+ :lockfile,
18
+ :gemfiles
18
19
  )
19
20
 
20
21
  # Given a gemfile and lockfile creates a Bundler definition
@@ -51,8 +52,16 @@ module Bundler
51
52
  # to be updated or true if all gems should be updated
52
53
  # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
53
54
  # @param optional_groups [Array(String)] A list of optional groups
54
- def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [])
55
- @unlocking = unlock == true || !unlock.empty?
55
+ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
56
+ if [true, false].include?(unlock)
57
+ @unlocking_bundler = false
58
+ @unlocking = unlock
59
+ else
60
+ unlock = unlock.dup
61
+ @unlocking_bundler = unlock.delete(:bundler)
62
+ unlock.delete_if {|_k, v| Array(v).empty? }
63
+ @unlocking = !unlock.empty?
64
+ end
56
65
 
57
66
  @dependencies = dependencies
58
67
  @sources = sources
@@ -61,11 +70,13 @@ module Bundler
61
70
  @remote = false
62
71
  @specs = nil
63
72
  @ruby_version = ruby_version
73
+ @gemfiles = gemfiles
64
74
 
65
75
  @lockfile = lockfile
66
76
  @lockfile_contents = String.new
67
77
  @locked_bundler_version = nil
68
78
  @locked_ruby_version = nil
79
+ @locked_specs_incomplete_for_platform = false
69
80
 
70
81
  if lockfile && File.exist?(lockfile)
71
82
  @lockfile_contents = Bundler.read_file(lockfile)
@@ -102,36 +113,36 @@ module Bundler
102
113
  end
103
114
  @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
104
115
 
105
- add_current_platform unless Bundler.settings[:frozen]
116
+ add_current_platform unless Bundler.frozen_bundle?
106
117
 
107
118
  converge_path_sources_to_gemspec_sources
108
119
  @path_changes = converge_paths
109
120
  @source_changes = converge_sources
110
121
 
111
122
  unless @unlock[:lock_shared_dependencies]
112
- eager_unlock = expand_dependencies(@unlock[:gems])
113
- @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
123
+ eager_unlock = expand_dependencies(@unlock[:gems], true)
124
+ @unlock[:gems] = @locked_specs.for(eager_unlock, [], false, false, false).map(&:name)
114
125
  end
115
126
 
116
- @gem_version_promoter = create_gem_version_promoter
117
-
118
127
  @dependency_changes = converge_dependencies
119
128
  @local_changes = converge_locals
120
129
 
121
130
  @requires = compute_requires
122
131
  end
123
132
 
124
- def create_gem_version_promoter
125
- locked_specs =
126
- if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty?
127
- # Definition uses an empty set of locked_specs to indicate all gems
128
- # are unlocked, but GemVersionPromoter needs the locked_specs
129
- # for conservative comparison.
130
- Bundler::SpecSet.new(@locked_gems.specs)
131
- else
132
- @locked_specs
133
- end
134
- GemVersionPromoter.new(locked_specs, @unlock[:gems])
133
+ def gem_version_promoter
134
+ @gem_version_promoter ||= begin
135
+ locked_specs =
136
+ if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty?
137
+ # Definition uses an empty set of locked_specs to indicate all gems
138
+ # are unlocked, but GemVersionPromoter needs the locked_specs
139
+ # for conservative comparison.
140
+ Bundler::SpecSet.new(@locked_gems.specs)
141
+ else
142
+ @locked_specs
143
+ end
144
+ GemVersionPromoter.new(locked_specs, @unlock[:gems])
145
+ end
135
146
  end
136
147
 
137
148
  def resolve_with_cache!
@@ -164,12 +175,11 @@ module Bundler
164
175
  raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
165
176
  "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
166
177
  "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
167
- "to a different version of #{locked_gem} that hasn't been removed in order to install."
178
+ "to a version other than #{locked_gem} that hasn't been removed in order to install."
168
179
  end
169
180
  unless specs["bundler"].any?
170
- local = Bundler.settings[:frozen] ? rubygems_index : index
171
- bundler = local.search(Gem::Dependency.new("bundler", VERSION)).last
172
- specs["bundler"] = bundler if bundler
181
+ bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
182
+ specs["bundler"] = bundler
173
183
  end
174
184
 
175
185
  specs
@@ -194,10 +204,19 @@ module Bundler
194
204
  missing
195
205
  end
196
206
 
197
- def missing_dependencies
198
- missing = []
199
- resolve.materialize(current_dependencies, missing)
200
- missing
207
+ def missing_specs?
208
+ missing = missing_specs
209
+ return false if missing.empty?
210
+ Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
211
+ true
212
+ rescue BundlerError => e
213
+ @index = nil
214
+ @resolve = nil
215
+ @specs = nil
216
+ @gem_version_promoter = nil
217
+
218
+ Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
219
+ true
201
220
  end
202
221
 
203
222
  def requested_specs
@@ -226,14 +245,22 @@ module Bundler
226
245
  def resolve
227
246
  @resolve ||= begin
228
247
  last_resolve = converge_locked_specs
229
- if Bundler.settings[:frozen] || (!unlocking? && nothing_changed?)
230
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
231
- last_resolve
232
- else
233
- # Run a resolve against the locally available gems
234
- Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
235
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
236
- end
248
+ resolve =
249
+ if Bundler.frozen_bundle?
250
+ Bundler.ui.debug "Frozen, using resolution from the lockfile"
251
+ last_resolve
252
+ elsif !unlocking? && nothing_changed?
253
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
254
+ last_resolve
255
+ else
256
+ # Run a resolve against the locally available gems
257
+ Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
258
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
259
+ end
260
+
261
+ # filter out gems that _can_ be installed on multiple platforms, but don't need
262
+ # to be
263
+ resolve.for(expand_dependencies(dependencies, true), [], false, false, false)
237
264
  end
238
265
  end
239
266
 
@@ -242,25 +269,44 @@ module Bundler
242
269
  dependency_names = @dependencies.map(&:name)
243
270
 
244
271
  sources.all_sources.each do |source|
245
- source.dependency_names = dependency_names.dup
272
+ source.dependency_names = dependency_names - pinned_spec_names(source)
246
273
  idx.add_source source.specs
247
- dependency_names -= pinned_spec_names(source.specs)
248
274
  dependency_names.concat(source.unmet_deps).uniq!
249
275
  end
250
- idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
251
- idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
252
- end
253
- end
254
276
 
255
- # used when frozen is enabled so we can find the bundler
256
- # spec, even if (say) a git gem is not checked out.
257
- def rubygems_index
258
- @rubygems_index ||= Index.build do |idx|
259
- sources.rubygems_sources.each do |rubygems|
260
- idx.add_source rubygems.specs
277
+ double_check_for_index(idx, dependency_names)
278
+ end
279
+ end
280
+
281
+ # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
282
+ # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
283
+ # but will not have found any versions of Bar from source B, which is a problem if the requested version
284
+ # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
285
+ # each spec we found, we add all possible versions from all sources to the index.
286
+ def double_check_for_index(idx, dependency_names)
287
+ pinned_names = pinned_spec_names
288
+ loop do
289
+ idxcount = idx.size
290
+
291
+ names = :names # do this so we only have to traverse to get dependency_names from the index once
292
+ unmet_dependency_names = lambda do
293
+ return names unless names == :names
294
+ new_names = sources.all_sources.map(&:dependency_names_to_double_check)
295
+ return names = nil if new_names.compact!
296
+ names = new_names.flatten(1).concat(dependency_names)
297
+ names.uniq!
298
+ names -= pinned_names
299
+ names
300
+ end
301
+
302
+ sources.all_sources.each do |source|
303
+ source.double_check_for(unmet_dependency_names)
261
304
  end
305
+
306
+ break if idxcount == idx.size
262
307
  end
263
308
  end
309
+ private :double_check_for_index
264
310
 
265
311
  def has_rubygems_remotes?
266
312
  sources.rubygems_sources.any? {|s| s.remotes.any? }
@@ -295,10 +341,11 @@ module Bundler
295
341
  end
296
342
  end
297
343
 
298
- preserve_unknown_sections ||= !updating_major && (Bundler.settings[:frozen] || !unlocking?)
299
- return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
344
+ preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
345
+
346
+ return if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
300
347
 
301
- if Bundler.settings[:frozen]
348
+ if Bundler.frozen_bundle?
302
349
  Bundler.ui.error "Cannot write a changed lockfile while frozen."
303
350
  return
304
351
  end
@@ -338,51 +385,8 @@ module Bundler
338
385
  end
339
386
 
340
387
  def to_lock
341
- out = String.new
342
-
343
- sources.lock_sources.each do |source|
344
- # Add the source header
345
- out << source.to_lock
346
- # Find all specs for this source
347
- resolve.
348
- select {|s| source.can_lock?(s) }.
349
- # This needs to be sorted by full name so that
350
- # gems with the same name, but different platform
351
- # are ordered consistently
352
- sort_by(&:full_name).
353
- each do |spec|
354
- next if spec.name == "bundler"
355
- out << spec.to_lock
356
- end
357
- out << "\n"
358
- end
359
-
360
- out << "PLATFORMS\n"
361
-
362
- platforms.map(&:to_s).sort.each do |p|
363
- out << " #{p}\n"
364
- end
365
-
366
- out << "\n"
367
- out << "DEPENDENCIES\n"
368
-
369
- handled = []
370
- dependencies.sort_by(&:to_s).each do |dep|
371
- next if handled.include?(dep.name)
372
- out << dep.to_lock
373
- handled << dep.name
374
- end
375
-
376
- if locked_ruby_version
377
- out << "\nRUBY VERSION\n"
378
- out << " #{locked_ruby_version}\n"
379
- end
380
-
381
- # Record the version of Bundler that was used to create the lockfile
382
- out << "\nBUNDLED WITH\n"
383
- out << " #{locked_bundler_version}\n"
384
-
385
- out
388
+ require "bundler/lockfile_generator"
389
+ LockfileGenerator.generate(self)
386
390
  end
387
391
 
388
392
  def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
@@ -392,8 +396,13 @@ module Bundler
392
396
  "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
393
397
 
394
398
  unless explicit_flag
395
-
396
- suggested_command = Bundler.settings.locations("frozen")[:global] == "1" ? "bundle config --delete frozen" : "bundle install --no-deployment"
399
+ suggested_command = if Bundler.settings.locations("frozen")[:global]
400
+ "bundle config --delete frozen"
401
+ elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
402
+ "bundle config --delete deployment"
403
+ else
404
+ "bundle install --no-deployment"
405
+ end
397
406
  msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
398
407
  "freeze \nby running `#{suggested_command}`."
399
408
  end
@@ -417,8 +426,8 @@ module Bundler
417
426
 
418
427
  # Check if it is possible that the source is only changed thing
419
428
  if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
420
- new_sources.reject! {|source| source.is_a_path? && source.path.exist? }
421
- deleted_sources.reject! {|source| source.is_a_path? && source.path.exist? }
429
+ new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
430
+ deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
422
431
  end
423
432
 
424
433
  if @locked_sources != gemfile_sources
@@ -511,7 +520,7 @@ module Bundler
511
520
 
512
521
  def add_current_platform
513
522
  current_platform = Bundler.local_platform
514
- add_platform(current_platform) if Bundler.settings[:specific_platform]
523
+ add_platform(current_platform) if Bundler.feature_flag.specific_platform?
515
524
  add_platform(generic(current_platform))
516
525
  end
517
526
 
@@ -527,7 +536,7 @@ module Bundler
527
536
  private :sources
528
537
 
529
538
  def nothing_changed?
530
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes
539
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform
531
540
  end
532
541
 
533
542
  def unlocking?
@@ -554,14 +563,12 @@ module Bundler
554
563
  [@new_platform, "you added a new platform to your gemfile"],
555
564
  [@path_changes, "the gemspecs for path gems changed"],
556
565
  [@local_changes, "the gemspecs for git local gems changed"],
566
+ [@locked_specs_incomplete_for_platform, "the lockfile does not have all gems needed for the current platform"],
557
567
  ].select(&:first).map(&:last).join(", ")
558
568
  end
559
569
 
560
570
  def pretty_dep(dep, source = false)
561
- msg = String.new(dep.name)
562
- msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
563
- msg << " from the `#{dep.source}` source" if source && dep.source
564
- msg
571
+ SharedHelpers.pretty_dependency(dep, source)
565
572
  end
566
573
 
567
574
  # Check if the specs of the given source changed
@@ -585,6 +592,9 @@ module Bundler
585
592
 
586
593
  # order here matters, since Index#== is checking source.specs.include?(locked_index)
587
594
  locked_index != source.specs
595
+ rescue PathError, GitError => e
596
+ Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
597
+ false
588
598
  end
589
599
 
590
600
  # Get all locals and override their matching sources.
@@ -632,22 +642,32 @@ module Bundler
632
642
  end
633
643
  end
634
644
 
635
- def converge_sources
645
+ def converge_rubygems_sources
646
+ return false if Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
647
+
636
648
  changes = false
637
649
 
638
- # Get the Rubygems sources from the Gemfile.lock
650
+ # Get the RubyGems sources from the Gemfile.lock
639
651
  locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
640
- # Get the Rubygems remotes from the Gemfile
652
+ # Get the RubyGems remotes from the Gemfile
641
653
  actual_remotes = sources.rubygems_remotes
642
654
 
643
- # If there is a Rubygems source in both
655
+ # If there is a RubyGems source in both
644
656
  if !locked_gem_sources.empty? && !actual_remotes.empty?
645
657
  locked_gem_sources.each do |locked_gem|
646
658
  # Merge the remotes from the Gemfile into the Gemfile.lock
647
- changes |= locked_gem.replace_remotes(actual_remotes)
659
+ changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
648
660
  end
649
661
  end
650
662
 
663
+ changes
664
+ end
665
+
666
+ def converge_sources
667
+ changes = false
668
+
669
+ changes |= converge_rubygems_sources
670
+
651
671
  # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
652
672
  # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
653
673
  # source in the Gemfile.lock, use the one from the Gemfile.
@@ -669,7 +689,7 @@ module Bundler
669
689
  end
670
690
 
671
691
  def converge_dependencies
672
- frozen = Bundler.settings[:frozen]
692
+ frozen = Bundler.frozen_bundle?
673
693
  (@dependencies + @locked_deps.values).each do |dep|
674
694
  locked_source = @locked_deps[dep.name]
675
695
  # This is to make sure that if bundler is installing in deployment mode and
@@ -739,6 +759,8 @@ module Bundler
739
759
  end
740
760
  end
741
761
 
762
+ unlock_source_unlocks_spec = Bundler.feature_flag.unlock_source_unlocks_spec?
763
+
742
764
  converged = []
743
765
  @locked_specs.each do |s|
744
766
  # Replace the locked dependency's source with the equivalent source from the Gemfile
@@ -746,21 +768,33 @@ module Bundler
746
768
  s.source = (dep && dep.source) || sources.get(s.source)
747
769
 
748
770
  # Don't add a spec to the list if its source is expired. For example,
749
- # if you change a Git gem to Rubygems.
771
+ # if you change a Git gem to RubyGems.
750
772
  next if s.source.nil?
751
773
  next if @unlock[:sources].include?(s.source.name)
752
774
 
753
775
  # XXX This is a backwards-compatibility fix to preserve the ability to
754
776
  # unlock a single gem by passing its name via `--source`. See issue #3759
755
777
  # TODO: delete in Bundler 2
756
- next if @unlock[:sources].include?(s.name)
778
+ next if unlock_source_unlocks_spec && @unlock[:sources].include?(s.name)
757
779
 
758
780
  # If the spec is from a path source and it doesn't exist anymore
759
781
  # then we unlock it.
760
782
 
761
783
  # Path sources have special logic
762
784
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
763
- other = s.source.specs[s].first
785
+ other_sources_specs = begin
786
+ s.source.specs
787
+ rescue PathError, GitError
788
+ # if we won't need the source (according to the lockfile),
789
+ # don't error if the path/git source isn't available
790
+ next if @locked_specs.
791
+ for(requested_dependencies, [], false, true, false).
792
+ none? {|locked_spec| locked_spec.source == s.source }
793
+
794
+ raise
795
+ end
796
+
797
+ other = other_sources_specs[s].first
764
798
 
765
799
  # If the spec is no longer in the path source, unlock it. This
766
800
  # commonly happens if the version changed in the gemspec
@@ -776,7 +810,9 @@ module Bundler
776
810
  end
777
811
 
778
812
  resolve = SpecSet.new(converged)
779
- resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems], false, false, false)
813
+ expanded_deps = expand_dependencies(deps, true)
814
+ @locked_specs_incomplete_for_platform = !resolve.for(expanded_deps, @unlock[:gems], true, true)
815
+ resolve = resolve.for(expanded_deps, @unlock[:gems], false, false, false)
780
816
  diff = nil
781
817
 
782
818
  # Now, we unlock any sources that do not have anymore gems pinned to it
@@ -807,17 +843,21 @@ module Bundler
807
843
  # the metadata dependencies here
808
844
  def expanded_dependencies
809
845
  @expanded_dependencies ||= begin
846
+ expand_dependencies(dependencies + metadata_dependencies, @remote)
847
+ end
848
+ end
849
+
850
+ def metadata_dependencies
851
+ @metadata_dependencies ||= begin
810
852
  ruby_versions = concat_ruby_version_requirements(@ruby_version)
811
853
  if ruby_versions.empty? || !@ruby_version.exact?
812
854
  concat_ruby_version_requirements(RubyVersion.system)
813
855
  concat_ruby_version_requirements(locked_ruby_version_object) unless @unlock[:ruby]
814
856
  end
815
-
816
- metadata_dependencies = [
857
+ [
817
858
  Dependency.new("ruby\0", ruby_versions),
818
859
  Dependency.new("rubygems\0", Gem::VERSION),
819
860
  ]
820
- expand_dependencies(dependencies + metadata_dependencies, @remote)
821
861
  end
822
862
  end
823
863
 
@@ -838,12 +878,13 @@ module Bundler
838
878
  end
839
879
 
840
880
  def expand_dependencies(dependencies, remote = false)
881
+ sorted_platforms = Resolver.sort_platforms(@platforms)
841
882
  deps = []
842
883
  dependencies.each do |dep|
843
884
  dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
844
885
  next if !remote && !dep.current_platform?
845
- platforms = dep.gem_platforms(@platforms)
846
- if platforms.empty?
886
+ platforms = dep.gem_platforms(sorted_platforms)
887
+ if platforms.empty? && !Bundler.settings[:disable_platform_warnings]
847
888
  mapped_platforms = dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }
848
889
  Bundler.ui.warn \
849
890
  "The dependency #{dep} will be unused by any of the platforms Bundler is installing for. " \
@@ -872,30 +913,33 @@ module Bundler
872
913
  # Record the specs available in each gem's source, so that those
873
914
  # specs will be available later when the resolver knows where to
874
915
  # look for that gemspec (or its dependencies)
875
- source_requirements = {}
916
+ default = sources.default_source
917
+ source_requirements = { :default => default }
918
+ default = nil unless Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
876
919
  dependencies.each do |dep|
877
- next unless dep.source
878
- source_requirements[dep.name] = dep.source.specs
920
+ next unless source = dep.source || default
921
+ source_requirements[dep.name] = source
922
+ end
923
+ metadata_dependencies.each do |dep|
924
+ source_requirements[dep.name] = sources.metadata_source
879
925
  end
926
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
880
927
  source_requirements
881
928
  end
882
929
 
883
- def pinned_spec_names(specs)
884
- names = []
885
- specs.each do |s|
886
- # TODO: when two sources without blocks is an error, we can change
887
- # this check to !s.source.is_a?(Source::LocalRubygems). For now,
888
- # we need to ask every Rubygems for every gem name.
889
- if s.source.is_a?(Source::Git) || s.source.is_a?(Source::Path)
890
- names << s.name
891
- end
930
+ def pinned_spec_names(skip = nil)
931
+ pinned_names = []
932
+ default = Bundler.feature_flag.lockfile_uses_separate_rubygems_sources? && sources.default_source
933
+ @dependencies.each do |dep|
934
+ next unless dep_source = dep.source || default
935
+ next if dep_source == skip
936
+ pinned_names << dep.name
892
937
  end
893
- names.uniq!
894
- names
938
+ pinned_names
895
939
  end
896
940
 
897
941
  def requested_groups
898
- groups - Bundler.settings.without - @optional_groups + Bundler.settings.with
942
+ groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
899
943
  end
900
944
 
901
945
  def lockfiles_equal?(current, proposed, preserve_unknown_sections)
@@ -930,11 +974,20 @@ module Bundler
930
974
 
931
975
  def additional_base_requirements_for_resolve
932
976
  return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
977
+ dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
933
978
  @locked_gems.specs.reduce({}) do |requirements, locked_spec|
934
- dep = Gem::Dependency.new(locked_spec.name, ">= #{locked_spec.version}")
935
- requirements[locked_spec.name] = DepProxy.new(dep, locked_spec.platform)
979
+ name = locked_spec.name
980
+ next requirements if @locked_gems.dependencies[name] != dependencies_by_name[name]
981
+ dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
982
+ requirements[name] = DepProxy.new(dep, locked_spec.platform)
936
983
  requirements
937
984
  end.values
938
985
  end
986
+
987
+ def equivalent_rubygems_remotes?(source)
988
+ return false unless source.is_a?(Source::Rubygems)
989
+
990
+ Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
991
+ end
939
992
  end
940
993
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class DepProxy
4
5
  attr_reader :__platform, :dep
@@ -9,10 +10,11 @@ module Bundler
9
10
  end
10
11
 
11
12
  def hash
12
- @hash ||= dep.hash
13
+ @hash ||= [dep, __platform].hash
13
14
  end
14
15
 
15
16
  def ==(other)
17
+ return false if other.class != self.class
16
18
  dep == other.dep && __platform == other.__platform
17
19
  end
18
20
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "rubygems/dependency"
3
4
  require "bundler/shared_helpers"
4
5
  require "bundler/rubygems_ext"
@@ -6,8 +7,7 @@ require "bundler/rubygems_ext"
6
7
  module Bundler
7
8
  class Dependency < Gem::Dependency
8
9
  attr_reader :autorequire
9
- attr_reader :groups
10
- attr_reader :platforms
10
+ attr_reader :groups, :platforms, :gemfile
11
11
 
12
12
  PLATFORM_MAP = {
13
13
  :ruby => Gem::Platform::RUBY,
@@ -29,6 +29,7 @@ module Bundler
29
29
  :mri_24 => Gem::Platform::RUBY,
30
30
  :mri_25 => Gem::Platform::RUBY,
31
31
  :rbx => Gem::Platform::RUBY,
32
+ :truffleruby => Gem::Platform::RUBY,
32
33
  :jruby => Gem::Platform::JAVA,
33
34
  :jruby_18 => Gem::Platform::JAVA,
34
35
  :jruby_19 => Gem::Platform::JAVA,
@@ -86,20 +87,19 @@ module Bundler
86
87
  @platforms = Array(options["platforms"])
87
88
  @env = options["env"]
88
89
  @should_include = options.fetch("should_include", true)
90
+ @gemfile = options["gemfile"]
89
91
 
90
92
  @autorequire = Array(options["require"] || []) if options.key?("require")
91
93
  end
92
94
 
95
+ # Returns the platforms this dependency is valid for, in the same order as
96
+ # passed in the `valid_platforms` parameter
93
97
  def gem_platforms(valid_platforms)
94
98
  return valid_platforms if @platforms.empty?
95
99
 
96
- platforms = []
97
- @platforms.each do |p|
98
- platform = PLATFORM_MAP[p]
99
- next unless valid_platforms.include?(platform)
100
- platforms |= [platform]
101
- end
102
- platforms
100
+ @gem_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq
101
+
102
+ valid_platforms & @gem_platforms
103
103
  end
104
104
 
105
105
  def should_include?
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/shared_helpers"
4
- Bundler::SharedHelpers.major_deprecation "Bundler no longer integrates with " \
4
+ Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \
5
5
  "Capistrano, but Capistrano provides its own integration with " \
6
6
  "Bundler via the capistrano-bundler gem. Use it instead."
7
7