bundler 2.1.4 → 2.2.17

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 (225) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1774 -1430
  3. data/README.md +6 -8
  4. data/bundler.gemspec +4 -4
  5. data/exe/bundle +3 -0
  6. data/lib/bundler.rb +33 -9
  7. data/lib/bundler/build_metadata.rb +3 -11
  8. data/lib/bundler/cli.rb +59 -23
  9. data/lib/bundler/cli/add.rb +1 -1
  10. data/lib/bundler/cli/binstubs.rb +6 -2
  11. data/lib/bundler/cli/cache.rb +2 -7
  12. data/lib/bundler/cli/clean.rb +1 -1
  13. data/lib/bundler/cli/common.rb +29 -2
  14. data/lib/bundler/cli/console.rb +1 -1
  15. data/lib/bundler/cli/doctor.rb +1 -1
  16. data/lib/bundler/cli/exec.rb +4 -4
  17. data/lib/bundler/cli/fund.rb +36 -0
  18. data/lib/bundler/cli/gem.rb +129 -28
  19. data/lib/bundler/cli/info.rb +15 -4
  20. data/lib/bundler/cli/init.rb +2 -2
  21. data/lib/bundler/cli/inject.rb +1 -1
  22. data/lib/bundler/cli/install.rb +13 -11
  23. data/lib/bundler/cli/issue.rb +2 -2
  24. data/lib/bundler/cli/list.rb +12 -10
  25. data/lib/bundler/cli/outdated.rb +88 -67
  26. data/lib/bundler/cli/plugin.rb +10 -0
  27. data/lib/bundler/cli/pristine.rb +5 -0
  28. data/lib/bundler/cli/show.rb +1 -1
  29. data/lib/bundler/cli/update.rb +3 -1
  30. data/lib/bundler/compact_index_client.rb +1 -1
  31. data/lib/bundler/compact_index_client/cache.rb +6 -14
  32. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  33. data/lib/bundler/compact_index_client/updater.rb +13 -17
  34. data/lib/bundler/current_ruby.rb +1 -0
  35. data/lib/bundler/definition.rb +121 -131
  36. data/lib/bundler/dep_proxy.rb +16 -9
  37. data/lib/bundler/dependency.rb +3 -10
  38. data/lib/bundler/dsl.rb +40 -33
  39. data/lib/bundler/endpoint_specification.rb +1 -1
  40. data/lib/bundler/env.rb +1 -1
  41. data/lib/bundler/environment_preserver.rb +26 -2
  42. data/lib/bundler/errors.rb +1 -0
  43. data/lib/bundler/feature_flag.rb +0 -5
  44. data/lib/bundler/fetcher.rb +5 -4
  45. data/lib/bundler/fetcher/base.rb +1 -1
  46. data/lib/bundler/fetcher/compact_index.rb +1 -1
  47. data/lib/bundler/fetcher/downloader.rb +9 -5
  48. data/lib/bundler/fetcher/index.rb +3 -4
  49. data/lib/bundler/friendly_errors.rb +22 -13
  50. data/lib/bundler/gem_helper.rb +51 -18
  51. data/lib/bundler/gem_helpers.rb +36 -25
  52. data/lib/bundler/gem_version_promoter.rb +4 -4
  53. data/lib/bundler/graph.rb +1 -1
  54. data/lib/bundler/index.rb +12 -7
  55. data/lib/bundler/injector.rb +23 -5
  56. data/lib/bundler/inline.rb +3 -2
  57. data/lib/bundler/installer.rb +37 -49
  58. data/lib/bundler/installer/gem_installer.rb +3 -3
  59. data/lib/bundler/installer/parallel_installer.rb +46 -25
  60. data/lib/bundler/installer/standalone.rb +17 -2
  61. data/lib/bundler/lazy_specification.rb +45 -25
  62. data/lib/bundler/lockfile_generator.rb +1 -1
  63. data/lib/bundler/lockfile_parser.rb +4 -14
  64. data/lib/bundler/man/.document +1 -0
  65. data/{man → lib/bundler/man}/bundle-add.1 +1 -1
  66. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +0 -0
  67. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  68. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  69. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  70. data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  71. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  72. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  73. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  74. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  75. data/{man → lib/bundler/man}/bundle-config.1 +42 -34
  76. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +51 -43
  77. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  78. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  79. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  80. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  81. data/{man → lib/bundler/man}/bundle-gem.1 +25 -3
  82. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +30 -7
  83. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  84. data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  85. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  86. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  87. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  88. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  89. data/{man → lib/bundler/man}/bundle-install.1 +30 -3
  90. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +25 -3
  91. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  92. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  93. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  94. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  95. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  96. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  97. data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
  98. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
  99. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  100. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  101. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  102. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  103. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  104. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  105. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  106. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  107. data/{man → lib/bundler/man}/bundle-update.1 +1 -1
  108. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +0 -0
  109. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  110. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  111. data/{man → lib/bundler/man}/bundle.1 +1 -1
  112. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  113. data/{man → lib/bundler/man}/gemfile.5 +4 -4
  114. data/{man → lib/bundler/man}/gemfile.5.ronn +4 -4
  115. data/{man → lib/bundler/man}/index.txt +0 -0
  116. data/lib/bundler/mirror.rb +2 -2
  117. data/lib/bundler/plugin.rb +33 -7
  118. data/lib/bundler/plugin/api/source.rb +8 -1
  119. data/lib/bundler/plugin/dsl.rb +1 -1
  120. data/lib/bundler/plugin/index.rb +10 -1
  121. data/lib/bundler/plugin/installer.rb +9 -11
  122. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  123. data/lib/bundler/plugin/source_list.rb +5 -1
  124. data/lib/bundler/psyched_yaml.rb +0 -15
  125. data/lib/bundler/remote_specification.rb +5 -2
  126. data/lib/bundler/resolver.rb +133 -77
  127. data/lib/bundler/resolver/spec_group.rb +75 -48
  128. data/lib/bundler/retry.rb +2 -2
  129. data/lib/bundler/ruby_version.rb +1 -1
  130. data/lib/bundler/rubygems_ext.rb +69 -9
  131. data/lib/bundler/rubygems_gem_installer.rb +50 -9
  132. data/lib/bundler/rubygems_integration.rb +25 -60
  133. data/lib/bundler/runtime.rb +4 -14
  134. data/lib/bundler/settings.rb +107 -54
  135. data/lib/bundler/shared_helpers.rb +3 -3
  136. data/lib/bundler/similarity_detector.rb +1 -1
  137. data/lib/bundler/source.rb +7 -1
  138. data/lib/bundler/source/git.rb +24 -22
  139. data/lib/bundler/source/git/git_proxy.rb +82 -80
  140. data/lib/bundler/source/metadata.rb +0 -4
  141. data/lib/bundler/source/path.rb +10 -4
  142. data/lib/bundler/source/path/installer.rb +10 -10
  143. data/lib/bundler/source/rubygems.rb +45 -24
  144. data/lib/bundler/source/rubygems/remote.rb +1 -1
  145. data/lib/bundler/source_list.rb +31 -26
  146. data/lib/bundler/spec_set.rb +29 -17
  147. data/lib/bundler/stub_specification.rb +25 -7
  148. data/lib/bundler/templates/Gemfile +1 -1
  149. data/lib/bundler/templates/gems.rb +1 -1
  150. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  151. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  152. data/lib/bundler/templates/newgem/Gemfile.tt +9 -1
  153. data/lib/bundler/templates/newgem/README.md.tt +6 -5
  154. data/lib/bundler/templates/newgem/Rakefile.tt +19 -5
  155. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  156. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  157. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  158. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +16 -0
  159. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  160. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  161. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  162. data/lib/bundler/templates/newgem/newgem.gemspec.tt +15 -7
  163. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  164. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  165. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  166. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  167. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  168. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  169. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  170. data/lib/bundler/ui/shell.rb +5 -5
  171. data/lib/bundler/uri_credentials_filter.rb +3 -1
  172. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  173. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  174. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +34 -2
  175. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  176. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  177. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +3 -3
  178. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  179. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  180. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  181. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  182. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  183. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  184. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  185. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  186. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  187. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  188. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  189. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  190. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  191. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  192. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  193. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  194. data/lib/bundler/vendored_persistent.rb +0 -7
  195. data/lib/bundler/vendored_tmpdir.rb +4 -0
  196. data/lib/bundler/version.rb +1 -1
  197. data/lib/bundler/worker.rb +1 -1
  198. data/lib/bundler/yaml_serializer.rb +1 -1
  199. metadata +71 -85
  200. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  201. data/man/bundle-add.1.txt +0 -58
  202. data/man/bundle-binstubs.1.txt +0 -48
  203. data/man/bundle-cache.1.txt +0 -78
  204. data/man/bundle-check.1.txt +0 -33
  205. data/man/bundle-clean.1.txt +0 -26
  206. data/man/bundle-config.1.txt +0 -528
  207. data/man/bundle-doctor.1.txt +0 -44
  208. data/man/bundle-exec.1.txt +0 -178
  209. data/man/bundle-gem.1.txt +0 -91
  210. data/man/bundle-info.1.txt +0 -21
  211. data/man/bundle-init.1.txt +0 -34
  212. data/man/bundle-inject.1.txt +0 -32
  213. data/man/bundle-install.1.txt +0 -401
  214. data/man/bundle-list.1.txt +0 -43
  215. data/man/bundle-lock.1.txt +0 -93
  216. data/man/bundle-open.1.txt +0 -29
  217. data/man/bundle-outdated.1.txt +0 -131
  218. data/man/bundle-platform.1.txt +0 -57
  219. data/man/bundle-pristine.1.txt +0 -44
  220. data/man/bundle-remove.1.txt +0 -34
  221. data/man/bundle-show.1.txt +0 -27
  222. data/man/bundle-update.1.txt +0 -390
  223. data/man/bundle-viz.1.txt +0 -39
  224. data/man/bundle.1.txt +0 -116
  225. data/man/gemfile.5.txt +0 -649
@@ -43,14 +43,6 @@ module Bundler
43
43
  self
44
44
  end
45
45
 
46
- REQUIRE_ERRORS = [
47
- /^no such file to load -- (.+)$/i,
48
- /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
49
- /^Missing API definition file in (.+)$/i,
50
- /^cannot load such file -- (.+)$/i,
51
- /^dlopen\([^)]*\): Library not loaded: (.+)$/i,
52
- ].freeze
53
-
54
46
  def require(*groups)
55
47
  groups.map!(&:to_sym)
56
48
  groups = [:default] if groups.empty?
@@ -79,16 +71,14 @@ module Bundler
79
71
  end
80
72
  end
81
73
  rescue LoadError => e
82
- REQUIRE_ERRORS.find {|r| r =~ e.message }
83
- raise if dep.autorequire || $1 != required_file
74
+ raise if dep.autorequire || e.path != required_file
84
75
 
85
76
  if dep.autorequire.nil? && dep.name.include?("-")
86
77
  begin
87
78
  namespaced_file = dep.name.tr("-", "/")
88
79
  Kernel.require namespaced_file
89
80
  rescue LoadError => e
90
- REQUIRE_ERRORS.find {|r| r =~ e.message }
91
- raise if $1 != namespaced_file
81
+ raise if e.path != namespaced_file
92
82
  end
93
83
  end
94
84
  end
@@ -165,7 +155,7 @@ module Bundler
165
155
  spec_cache_paths = []
166
156
  spec_gemspec_paths = []
167
157
  spec_extension_paths = []
168
- specs.each do |spec|
158
+ Bundler.rubygems.add_default_gems_to(specs).values.each do |spec|
169
159
  spec_gem_paths << spec.full_gem_path
170
160
  # need to check here in case gems are nested like for the rails git repo
171
161
  md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
@@ -213,7 +203,7 @@ module Bundler
213
203
  output
214
204
  end
215
205
 
216
- private
206
+ private
217
207
 
218
208
  def prune_gem_cache(resolve, cache_path)
219
209
  cached = Dir["#{cache_path}/*.gem"]
@@ -7,35 +7,36 @@ module Bundler
7
7
  autoload :Validator, File.expand_path("settings/validator", __dir__)
8
8
 
9
9
  BOOL_KEYS = %w[
10
- allow_bundler_dependency_conflicts
11
10
  allow_deployment_source_credential_changes
12
11
  allow_offline_install
13
12
  auto_clean_without_path
14
13
  auto_install
15
- auto_config_jobs
16
14
  cache_all
17
15
  cache_all_platforms
16
+ clean
18
17
  default_install_uses_path
19
18
  deployment
20
19
  deployment_means_frozen
21
20
  disable_checksum_validation
22
21
  disable_exec_load
23
22
  disable_local_branch_check
23
+ disable_local_revision_check
24
24
  disable_multisource
25
- disable_platform_warnings
26
25
  disable_shared_gems
27
26
  disable_version_check
28
27
  force_ruby_platform
29
28
  forget_cli_options
30
29
  frozen
30
+ gem.changelog
31
31
  gem.coc
32
32
  gem.mit
33
+ git.allow_insecure
33
34
  global_gem_cache
34
35
  ignore_messages
35
36
  init_gems_rb
37
+ inline
36
38
  no_install
37
39
  no_prune
38
- only_update_to_newer_versions
39
40
  path_relative_to_cwd
40
41
  path.system
41
42
  plugins
@@ -44,8 +45,6 @@ module Bundler
44
45
  setup_makes_kernel_gem_public
45
46
  silence_deprecations
46
47
  silence_root_warning
47
- skip_default_git_sources
48
- specific_platform
49
48
  suppress_install_using_messages
50
49
  unlock_source_unlocks_spec
51
50
  update_requires_all_flag
@@ -65,31 +64,42 @@ module Bundler
65
64
  without
66
65
  ].freeze
67
66
 
67
+ STRING_KEYS = %w[
68
+ bin
69
+ cache_path
70
+ console
71
+ gem.ci
72
+ gem.github_username
73
+ gem.linter
74
+ gem.rubocop
75
+ gem.test
76
+ gemfile
77
+ path
78
+ shebang
79
+ system_bindir
80
+ trust-policy
81
+ ].freeze
82
+
68
83
  DEFAULT_CONFIG = {
69
- :silence_deprecations => false,
70
- :disable_version_check => true,
71
- :prefer_patch => false,
72
- :redirect => 5,
73
- :retry => 3,
74
- :timeout => 10,
84
+ "BUNDLE_SILENCE_DEPRECATIONS" => false,
85
+ "BUNDLE_DISABLE_VERSION_CHECK" => true,
86
+ "BUNDLE_PREFER_PATCH" => false,
87
+ "BUNDLE_REDIRECT" => 5,
88
+ "BUNDLE_RETRY" => 3,
89
+ "BUNDLE_TIMEOUT" => 10,
75
90
  }.freeze
76
91
 
77
92
  def initialize(root = nil)
78
93
  @root = root
79
94
  @local_config = load_config(local_config_file)
95
+ @env_config = ENV.to_h.select {|key, _value| key =~ /\ABUNDLE_.+/ }
80
96
  @global_config = load_config(global_config_file)
81
97
  @temporary = {}
82
98
  end
83
99
 
84
100
  def [](name)
85
101
  key = key_for(name)
86
- value = @temporary.fetch(key) do
87
- @local_config.fetch(key) do
88
- ENV.fetch(key) do
89
- @global_config.fetch(key) do
90
- DEFAULT_CONFIG.fetch(name) do
91
- nil
92
- end end end end end
102
+ value = configs.values.map {|config| config[key] }.compact.first
93
103
 
94
104
  converted_value(value, name)
95
105
  end
@@ -132,13 +142,11 @@ module Bundler
132
142
  end
133
143
 
134
144
  def all
135
- env_keys = ENV.keys.grep(/\ABUNDLE_.+/)
136
-
137
- keys = @temporary.keys | @global_config.keys | @local_config.keys | env_keys
145
+ keys = @temporary.keys | @global_config.keys | @local_config.keys | @env_config.keys
138
146
 
139
147
  keys.map do |key|
140
- key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
141
- end
148
+ key.sub(/^BUNDLE_/, "").gsub(/___/, "-").gsub(/__/, ".").downcase
149
+ end.sort
142
150
  end
143
151
 
144
152
  def local_overrides
@@ -171,13 +179,11 @@ module Bundler
171
179
 
172
180
  def locations(key)
173
181
  key = key_for(key)
174
- locations = {}
175
- locations[:temporary] = @temporary[key] if @temporary.key?(key)
176
- locations[:local] = @local_config[key] if @local_config.key?(key)
177
- locations[:env] = ENV[key] if ENV[key]
178
- locations[:global] = @global_config[key] if @global_config.key?(key)
179
- locations[:default] = DEFAULT_CONFIG[key] if DEFAULT_CONFIG.key?(key)
180
- locations
182
+ configs.keys.inject({}) do |partial_locations, level|
183
+ value_on_level = configs[level][key]
184
+ partial_locations[level] = value_on_level unless value_on_level.nil?
185
+ partial_locations
186
+ end
181
187
  end
182
188
 
183
189
  def pretty_values_for(exposed_key)
@@ -185,20 +191,20 @@ module Bundler
185
191
 
186
192
  locations = []
187
193
 
188
- if @temporary.key?(key)
189
- locations << "Set for the current command: #{converted_value(@temporary[key], exposed_key).inspect}"
194
+ if value = @temporary[key]
195
+ locations << "Set for the current command: #{printable_value(value, exposed_key).inspect}"
190
196
  end
191
197
 
192
- if @local_config.key?(key)
193
- locations << "Set for your local app (#{local_config_file}): #{converted_value(@local_config[key], exposed_key).inspect}"
198
+ if value = @local_config[key]
199
+ locations << "Set for your local app (#{local_config_file}): #{printable_value(value, exposed_key).inspect}"
194
200
  end
195
201
 
196
- if value = ENV[key]
197
- locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}"
202
+ if value = @env_config[key]
203
+ locations << "Set via #{key}: #{printable_value(value, exposed_key).inspect}"
198
204
  end
199
205
 
200
- if @global_config.key?(key)
201
- locations << "Set for the current user (#{global_config_file}): #{converted_value(@global_config[key], exposed_key).inspect}"
206
+ if value = @global_config[key]
207
+ locations << "Set for the current user (#{global_config_file}): #{printable_value(value, exposed_key).inspect}"
202
208
  end
203
209
 
204
210
  return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
@@ -207,17 +213,19 @@ module Bundler
207
213
 
208
214
  # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
209
215
  def path
210
- key = key_for(:path)
211
- path = ENV[key] || @global_config[key]
212
- if path && !@temporary.key?(key) && !@local_config.key?(key)
213
- return Path.new(path, false, false)
216
+ configs.each do |_level, settings|
217
+ path = value_for("path", settings)
218
+ path_system = value_for("path.system", settings)
219
+ disabled_shared_gems = value_for("disable_shared_gems", settings)
220
+ next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
221
+ system_path = path_system || (disabled_shared_gems == false)
222
+ return Path.new(path, system_path)
214
223
  end
215
224
 
216
- system_path = self["path.system"] || (self[:disable_shared_gems] == false)
217
- Path.new(self[:path], system_path, Bundler.feature_flag.default_install_uses_path?)
225
+ Path.new(nil, false)
218
226
  end
219
227
 
220
- Path = Struct.new(:explicit_path, :system_path, :default_install_uses_path) do
228
+ Path = Struct.new(:explicit_path, :system_path) do
221
229
  def path
222
230
  path = base_path
223
231
  path = File.join(path, Bundler.ruby_scope) unless use_system_gems?
@@ -227,7 +235,7 @@ module Bundler
227
235
  def use_system_gems?
228
236
  return true if system_path
229
237
  return false if explicit_path
230
- !default_install_uses_path
238
+ !Bundler.feature_flag.default_install_uses_path?
231
239
  end
232
240
 
233
241
  def base_path
@@ -280,20 +288,32 @@ module Bundler
280
288
 
281
289
  def validate!
282
290
  all.each do |raw_key|
283
- [@local_config, ENV, @global_config].each do |settings|
284
- value = converted_value(settings[key_for(raw_key)], raw_key)
285
- Validator.validate!(raw_key, value, settings.to_hash.dup)
291
+ [@local_config, @env_config, @global_config].each do |settings|
292
+ value = value_for(raw_key, settings)
293
+ Validator.validate!(raw_key, value, settings.dup)
286
294
  end
287
295
  end
288
296
  end
289
297
 
290
298
  def key_for(key)
291
- key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
292
- key = key.to_s.gsub(".", "__").upcase
293
- "BUNDLE_#{key}"
299
+ self.class.key_for(key)
294
300
  end
295
301
 
296
- private
302
+ private
303
+
304
+ def configs
305
+ {
306
+ :temporary => @temporary,
307
+ :local => @local_config,
308
+ :env => @env_config,
309
+ :global => @global_config,
310
+ :default => DEFAULT_CONFIG,
311
+ }
312
+ end
313
+
314
+ def value_for(name, config)
315
+ converted_value(config[key_for(name)], name)
316
+ end
297
317
 
298
318
  def parent_setting_for(name)
299
319
  split_specific_setting_for(name)[0]
@@ -311,6 +331,10 @@ module Bundler
311
331
  BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s))
312
332
  end
313
333
 
334
+ def is_string(name)
335
+ STRING_KEYS.include?(name.to_s) || name.to_s.start_with?("local.") || name.to_s.start_with?("mirror.") || name.to_s.start_with?("build.")
336
+ end
337
+
314
338
  def to_bool(value)
315
339
  case value
316
340
  when nil, /\A(false|f|no|n|0|)\z/i, false
@@ -328,6 +352,14 @@ module Bundler
328
352
  ARRAY_KEYS.include?(key.to_s)
329
353
  end
330
354
 
355
+ def is_credential(key)
356
+ key == "gem.push_key"
357
+ end
358
+
359
+ def is_userinfo(value)
360
+ value.include?(":")
361
+ end
362
+
331
363
  def to_array(value)
332
364
  return [] unless value
333
365
  value.split(":").map(&:to_sym)
@@ -374,6 +406,21 @@ module Bundler
374
406
  end
375
407
  end
376
408
 
409
+ def printable_value(value, key)
410
+ converted = converted_value(value, key)
411
+ return converted unless converted.is_a?(String)
412
+
413
+ if is_string(key)
414
+ converted
415
+ elsif is_credential(key)
416
+ "[REDACTED]"
417
+ elsif is_userinfo(converted)
418
+ converted.gsub(/:.*$/, ":[REDACTED]")
419
+ else
420
+ converted
421
+ end
422
+ end
423
+
377
424
  def global_config_file
378
425
  if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
379
426
  Pathname.new(ENV["BUNDLE_CONFIG"])
@@ -413,6 +460,12 @@ module Bundler
413
460
  \z
414
461
  /ix.freeze
415
462
 
463
+ def self.key_for(key)
464
+ key = normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
465
+ key = key.to_s.gsub(".", "__").gsub("-", "___").upcase
466
+ "BUNDLE_#{key}"
467
+ end
468
+
416
469
  # TODO: duplicates Rubygems#normalize_uri
417
470
  # TODO: is this the correct place to validate mirror URIs?
418
471
  def self.normalize_uri(uri)
@@ -194,11 +194,11 @@ module Bundler
194
194
  return @md5_available if defined?(@md5_available)
195
195
  @md5_available = begin
196
196
  require "openssl"
197
- OpenSSL::Digest::MD5.digest("")
197
+ ::OpenSSL::Digest.digest("MD5", "")
198
198
  true
199
199
  rescue LoadError
200
200
  true
201
- rescue OpenSSL::Digest::DigestError
201
+ rescue ::OpenSSL::Digest::DigestError
202
202
  false
203
203
  end
204
204
  end
@@ -212,7 +212,7 @@ module Bundler
212
212
  filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
213
213
  end
214
214
 
215
- private
215
+ private
216
216
 
217
217
  def validate_bundle_path
218
218
  path_separator = Bundler.rubygems.path_separator
@@ -26,7 +26,7 @@ module Bundler
26
26
  end
27
27
  end
28
28
 
29
- protected
29
+ protected
30
30
 
31
31
  # https://www.informit.com/articles/article.aspx?p=683059&seqNum=36
32
32
  def levenshtein_distance(this, that, ins = 2, del = 2, sub = 1)
@@ -33,6 +33,12 @@ module Bundler
33
33
  spec.source == self
34
34
  end
35
35
 
36
+ def local!; end
37
+
38
+ def cached!; end
39
+
40
+ def remote!; end
41
+
36
42
  # it's possible that gems from one source depend on gems from some
37
43
  # other source, so now we download gemspecs and iterate over those
38
44
  # dependencies, looking for gems we don't have info on yet.
@@ -63,7 +69,7 @@ module Bundler
63
69
  )
64
70
  end
65
71
 
66
- private
72
+ private
67
73
 
68
74
  def version_color(spec_version, locked_spec_version)
69
75
  if Gem::Version.correct?(spec_version) && Gem::Version.correct?(locked_spec_version)
@@ -22,7 +22,7 @@ module Bundler
22
22
  @uri = options["uri"] || ""
23
23
  @safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
24
24
  @branch = options["branch"]
25
- @ref = options["ref"] || options["branch"] || options["tag"] || "master"
25
+ @ref = options["ref"] || options["branch"] || options["tag"]
26
26
  @submodules = options["submodules"]
27
27
  @name = options["name"]
28
28
  @version = options["version"].to_s.strip.gsub("-", ".pre.")
@@ -60,25 +60,27 @@ module Bundler
60
60
  alias_method :==, :eql?
61
61
 
62
62
  def to_s
63
- at = if local?
64
- path
65
- elsif user_ref = options["ref"]
66
- if ref =~ /\A[a-z0-9]{4,}\z/i
67
- shortref_for_display(user_ref)
63
+ begin
64
+ at = if local?
65
+ path
66
+ elsif user_ref = options["ref"]
67
+ if ref =~ /\A[a-z0-9]{4,}\z/i
68
+ shortref_for_display(user_ref)
69
+ else
70
+ user_ref
71
+ end
72
+ elsif ref
73
+ ref
68
74
  else
69
- user_ref
75
+ git_proxy.branch
70
76
  end
71
- else
72
- ref
73
- end
74
77
 
75
- rev = begin
76
- "@#{shortref_for_display(revision)}"
77
- rescue GitError
78
- nil
79
- end
78
+ rev = " (at #{at}@#{shortref_for_display(revision)})"
79
+ rescue GitError
80
+ ""
81
+ end
80
82
 
81
- "#{@safe_uri} (at #{at}#{rev})"
83
+ "#{@safe_uri}#{rev}"
82
84
  end
83
85
 
84
86
  def name
@@ -146,7 +148,7 @@ module Bundler
146
148
 
147
149
  changed = cached_revision && cached_revision != git_proxy.revision
148
150
 
149
- if changed && !@unlocked && !git_proxy.contains?(cached_revision)
151
+ if !Bundler.settings[:disable_local_revision_check] && changed && !@unlocked && !git_proxy.contains?(cached_revision)
150
152
  raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
151
153
  "but the current branch in your local override for #{name} does not contain such commit. " \
152
154
  "Please make sure your branch is up to date."
@@ -230,7 +232,11 @@ module Bundler
230
232
  @allow_remote || @allow_cached
231
233
  end
232
234
 
233
- private
235
+ def local?
236
+ @local
237
+ end
238
+
239
+ private
234
240
 
235
241
  def serialize_gemspecs_in(destination)
236
242
  destination = destination.expand_path(Bundler.root) if destination.relative?
@@ -256,10 +262,6 @@ module Bundler
256
262
  cached_revision && super
257
263
  end
258
264
 
259
- def local?
260
- @local
261
- end
262
-
263
265
  def requires_checkout?
264
266
  allow_git_ops? && !local? && !cached_revision_checked_out?
265
267
  end