rubygems-update 3.7.1 → 4.0.0.beta1

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 (219) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1434 -1317
  3. data/CODE_OF_CONDUCT.md +7 -129
  4. data/Manifest.txt +5 -11
  5. data/README.md +2 -2
  6. data/bundler/CHANGELOG.md +1001 -902
  7. data/bundler/README.md +4 -4
  8. data/bundler/bundler.gemspec +3 -3
  9. data/bundler/lib/bundler/build_metadata.rb +2 -2
  10. data/bundler/lib/bundler/capistrano.rb +1 -19
  11. data/bundler/lib/bundler/checksum.rb +6 -0
  12. data/bundler/lib/bundler/cli/cache.rb +1 -12
  13. data/bundler/lib/bundler/cli/common.rb +21 -4
  14. data/bundler/lib/bundler/cli/config.rb +1 -2
  15. data/bundler/lib/bundler/cli/console.rb +5 -0
  16. data/bundler/lib/bundler/cli/exec.rb +29 -4
  17. data/bundler/lib/bundler/cli/gem.rb +19 -33
  18. data/bundler/lib/bundler/cli/install.rb +7 -84
  19. data/bundler/lib/bundler/cli/issue.rb +2 -2
  20. data/bundler/lib/bundler/cli/list.rb +33 -2
  21. data/bundler/lib/bundler/cli/lock.rb +5 -5
  22. data/bundler/lib/bundler/cli/plugin.rb +5 -1
  23. data/bundler/lib/bundler/cli/show.rb +3 -7
  24. data/bundler/lib/bundler/cli/update.rb +3 -3
  25. data/bundler/lib/bundler/cli.rb +97 -95
  26. data/bundler/lib/bundler/compact_index_client.rb +0 -1
  27. data/bundler/lib/bundler/current_ruby.rb +3 -15
  28. data/bundler/lib/bundler/definition.rb +122 -95
  29. data/bundler/lib/bundler/deployment.rb +1 -64
  30. data/bundler/lib/bundler/digest.rb +1 -1
  31. data/bundler/lib/bundler/dsl.rb +14 -36
  32. data/bundler/lib/bundler/endpoint_specification.rb +0 -22
  33. data/bundler/lib/bundler/errors.rb +1 -5
  34. data/bundler/lib/bundler/feature_flag.rb +0 -33
  35. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  36. data/bundler/lib/bundler/friendly_errors.rb +2 -2
  37. data/bundler/lib/bundler/index.rb +0 -7
  38. data/bundler/lib/bundler/inline.rb +1 -1
  39. data/bundler/lib/bundler/installer/gem_installer.rb +0 -11
  40. data/bundler/lib/bundler/installer.rb +0 -6
  41. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  42. data/bundler/lib/bundler/lockfile_parser.rb +2 -12
  43. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-binstubs.1 +3 -6
  45. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  46. data/bundler/lib/bundler/man/bundle-cache.1 +2 -14
  47. data/bundler/lib/bundler/man/bundle-cache.1.ronn +1 -14
  48. data/bundler/lib/bundler/man/bundle-check.1 +2 -5
  49. data/bundler/lib/bundler/man/bundle-check.1.ronn +0 -5
  50. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  51. data/bundler/lib/bundler/man/bundle-config.1 +36 -46
  52. data/bundler/lib/bundler/man/bundle-config.1.ronn +69 -75
  53. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-doctor.1 +4 -4
  55. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +4 -4
  56. data/bundler/lib/bundler/man/bundle-env.1 +1 -1
  57. data/bundler/lib/bundler/man/bundle-exec.1 +2 -5
  58. data/bundler/lib/bundler/man/bundle-exec.1.ronn +1 -5
  59. data/bundler/lib/bundler/man/bundle-fund.1 +1 -1
  60. data/bundler/lib/bundler/man/bundle-gem.1 +3 -6
  61. data/bundler/lib/bundler/man/bundle-gem.1.ronn +2 -5
  62. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  64. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  65. data/bundler/lib/bundler/man/bundle-install.1 +8 -59
  66. data/bundler/lib/bundler/man/bundle-install.1.ronn +12 -107
  67. data/bundler/lib/bundler/man/bundle-issue.1 +1 -1
  68. data/bundler/lib/bundler/man/bundle-licenses.1 +1 -1
  69. data/bundler/lib/bundler/man/bundle-list.1 +6 -1
  70. data/bundler/lib/bundler/man/bundle-list.1.ronn +5 -0
  71. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  72. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  73. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  74. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  75. data/bundler/lib/bundler/man/bundle-plugin.1 +33 -15
  76. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +36 -15
  77. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  78. data/bundler/lib/bundler/man/bundle-remove.1 +2 -8
  79. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -8
  80. data/bundler/lib/bundler/man/bundle-show.1 +2 -5
  81. data/bundler/lib/bundler/man/bundle-show.1.ronn +0 -4
  82. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  83. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  84. data/bundler/lib/bundler/man/bundle.1 +1 -10
  85. data/bundler/lib/bundler/man/bundle.1.ronn +0 -9
  86. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  87. data/bundler/lib/bundler/man/index.txt +0 -2
  88. data/bundler/lib/bundler/materialization.rb +1 -1
  89. data/bundler/lib/bundler/plugin/installer.rb +0 -10
  90. data/bundler/lib/bundler/plugin/source_list.rb +1 -1
  91. data/bundler/lib/bundler/plugin.rb +1 -1
  92. data/bundler/lib/bundler/resolver/package.rb +1 -0
  93. data/bundler/lib/bundler/resolver.rb +1 -1
  94. data/bundler/lib/bundler/ruby_dsl.rb +2 -0
  95. data/bundler/lib/bundler/ruby_version.rb +1 -3
  96. data/bundler/lib/bundler/rubygems_ext.rb +1 -1
  97. data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
  98. data/bundler/lib/bundler/rubygems_integration.rb +1 -5
  99. data/bundler/lib/bundler/self_manager.rb +1 -1
  100. data/bundler/lib/bundler/settings.rb +8 -27
  101. data/bundler/lib/bundler/shared_helpers.rb +8 -20
  102. data/bundler/lib/bundler/source/gemspec.rb +4 -0
  103. data/bundler/lib/bundler/source/git/git_proxy.rb +3 -11
  104. data/bundler/lib/bundler/source/git.rb +2 -3
  105. data/bundler/lib/bundler/source/path.rb +5 -7
  106. data/bundler/lib/bundler/source/rubygems.rb +11 -17
  107. data/bundler/lib/bundler/source.rb +1 -1
  108. data/bundler/lib/bundler/source_list.rb +4 -45
  109. data/bundler/lib/bundler/source_map.rb +2 -5
  110. data/bundler/lib/bundler/spec_set.rb +6 -15
  111. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  112. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  113. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  114. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  115. data/bundler/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  116. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  117. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  118. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +6 -0
  119. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  120. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +7 -4
  121. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  122. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  123. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  124. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  125. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +5 -2
  126. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +42 -6
  127. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -1
  128. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +2 -2
  129. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +3 -7
  130. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  131. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  132. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  133. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  134. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  135. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  136. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  137. data/bundler/lib/bundler/version.rb +1 -1
  138. data/bundler/lib/bundler/vlad.rb +1 -14
  139. data/bundler/lib/bundler.rb +6 -28
  140. data/doc/MAINTAINERS.txt +0 -7
  141. data/doc/bundler/UPGRADING.md +11 -27
  142. data/doc/rubygems/CONTRIBUTING.md +1 -1
  143. data/lib/rubygems/basic_specification.rb +3 -9
  144. data/lib/rubygems/bundler_version_finder.rb +1 -0
  145. data/lib/rubygems/command.rb +1 -1
  146. data/lib/rubygems/command_manager.rb +3 -4
  147. data/lib/rubygems/commands/build_command.rb +0 -7
  148. data/lib/rubygems/commands/cert_command.rb +1 -1
  149. data/lib/rubygems/commands/install_command.rb +1 -5
  150. data/lib/rubygems/commands/setup_command.rb +5 -3
  151. data/lib/rubygems/commands/sources_command.rb +122 -18
  152. data/lib/rubygems/config_file.rb +1 -1
  153. data/lib/rubygems/defaults.rb +1 -1
  154. data/lib/rubygems/dependency.rb +1 -1
  155. data/lib/rubygems/dependency_installer.rb +0 -77
  156. data/lib/rubygems/dependency_list.rb +1 -2
  157. data/lib/rubygems/deprecate.rb +74 -72
  158. data/lib/rubygems/doctor.rb +1 -1
  159. data/lib/rubygems/errors.rb +1 -1
  160. data/lib/rubygems/exceptions.rb +5 -15
  161. data/lib/rubygems/ext/builder.rb +6 -2
  162. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  163. data/lib/rubygems/ext/cmake_builder.rb +97 -8
  164. data/lib/rubygems/ext/configure_builder.rb +2 -2
  165. data/lib/rubygems/ext/ext_conf_builder.rb +6 -2
  166. data/lib/rubygems/ext/rake_builder.rb +2 -2
  167. data/lib/rubygems/gem_runner.rb +0 -1
  168. data/lib/rubygems/install_update_options.rb +1 -2
  169. data/lib/rubygems/installer.rb +16 -54
  170. data/lib/rubygems/name_tuple.rb +7 -1
  171. data/lib/rubygems/package/tar_header.rb +4 -4
  172. data/lib/rubygems/package/tar_reader.rb +2 -0
  173. data/lib/rubygems/package/tar_writer.rb +1 -1
  174. data/lib/rubygems/package.rb +21 -12
  175. data/lib/rubygems/platform.rb +31 -11
  176. data/lib/rubygems/remote_fetcher.rb +8 -5
  177. data/lib/rubygems/resolver/conflict.rb +1 -1
  178. data/lib/rubygems/resolver.rb +1 -1
  179. data/lib/rubygems/s3_uri_signer.rb +54 -7
  180. data/lib/rubygems/security/signer.rb +1 -1
  181. data/lib/rubygems/source.rb +2 -2
  182. data/lib/rubygems/source_list.rb +36 -0
  183. data/lib/rubygems/spec_fetcher.rb +4 -4
  184. data/lib/rubygems/specification.rb +5 -96
  185. data/lib/rubygems/specification_policy.rb +0 -36
  186. data/lib/rubygems/specification_record.rb +1 -1
  187. data/lib/rubygems/text.rb +1 -1
  188. data/lib/rubygems/uninstaller.rb +17 -6
  189. data/lib/rubygems/user_interaction.rb +6 -9
  190. data/lib/rubygems/util.rb +0 -22
  191. data/lib/rubygems/validator.rb +1 -1
  192. data/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb +25 -9
  193. data/lib/rubygems/vendor/net-http/lib/net/http/responses.rb +2 -2
  194. data/lib/rubygems/vendor/net-http/lib/net/http.rb +14 -14
  195. data/lib/rubygems/vendor/optparse/lib/optparse.rb +82 -41
  196. data/lib/rubygems/vendor/resolv/lib/resolv.rb +1 -1
  197. data/lib/rubygems/vendor/timeout/lib/timeout.rb +4 -1
  198. data/lib/rubygems/vendor/uri/lib/uri/common.rb +57 -15
  199. data/lib/rubygems/vendor/uri/lib/uri/file.rb +1 -1
  200. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +34 -21
  201. data/lib/rubygems/vendor/uri/lib/uri/http.rb +12 -0
  202. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  203. data/lib/rubygems/vendor/uri/lib/uri/version.rb +2 -2
  204. data/lib/rubygems/version.rb +2 -17
  205. data/lib/rubygems/win_platform.rb +31 -0
  206. data/lib/rubygems.rb +10 -38
  207. data/rubygems-update.gemspec +4 -4
  208. metadata +10 -18
  209. data/bundler/lib/bundler/cli/inject.rb +0 -60
  210. data/bundler/lib/bundler/cli/viz.rb +0 -31
  211. data/bundler/lib/bundler/graph.rb +0 -152
  212. data/bundler/lib/bundler/man/bundle-inject.1 +0 -31
  213. data/bundler/lib/bundler/man/bundle-inject.1.ronn +0 -32
  214. data/bundler/lib/bundler/man/bundle-viz.1 +0 -30
  215. data/bundler/lib/bundler/man/bundle-viz.1.ronn +0 -36
  216. data/bundler/lib/bundler/similarity_detector.rb +0 -63
  217. data/lib/rubygems/commands/query_command.rb +0 -43
  218. data/lib/rubygems/compatibility.rb +0 -41
  219. data/lib/rubygems/install_default_message.rb +0 -13
@@ -18,6 +18,14 @@ class Gem::Commands::SourcesCommand < Gem::Command
18
18
  options[:add] = value
19
19
  end
20
20
 
21
+ add_option "--append SOURCE_URI", "Append source (can be used multiple times)" do |value, options|
22
+ options[:append] = value
23
+ end
24
+
25
+ add_option "-p", "--prepend SOURCE_URI", "Prepend source (can be used multiple times)" do |value, options|
26
+ options[:prepend] = value
27
+ end
28
+
21
29
  add_option "-l", "--list", "List sources" do |value, options|
22
30
  options[:list] = value
23
31
  end
@@ -26,8 +34,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
26
34
  options[:remove] = value
27
35
  end
28
36
 
29
- add_option "-c", "--clear-all",
30
- "Remove all sources (clear the cache)" do |value, options|
37
+ add_option "-c", "--clear-all", "Remove all sources (clear the cache)" do |value, options|
31
38
  options[:clear_all] = value
32
39
  end
33
40
 
@@ -68,6 +75,60 @@ class Gem::Commands::SourcesCommand < Gem::Command
68
75
  end
69
76
  end
70
77
 
78
+ def append_source(source_uri) # :nodoc:
79
+ check_rubygems_https source_uri
80
+
81
+ source = Gem::Source.new source_uri
82
+
83
+ check_typo_squatting(source)
84
+
85
+ begin
86
+ source.load_specs :released
87
+ was_present = Gem.sources.include?(source)
88
+ Gem.sources.append source
89
+ Gem.configuration.write
90
+
91
+ if was_present
92
+ say "#{source_uri} moved to end of sources"
93
+ else
94
+ say "#{source_uri} added to sources"
95
+ end
96
+ rescue Gem::URI::Error, ArgumentError
97
+ say "#{source_uri} is not a URI"
98
+ terminate_interaction 1
99
+ rescue Gem::RemoteFetcher::FetchError => e
100
+ say "Error fetching #{Gem::Uri.redact(source.uri)}:\n\t#{e.message}"
101
+ terminate_interaction 1
102
+ end
103
+ end
104
+
105
+ def prepend_source(source_uri) # :nodoc:
106
+ check_rubygems_https source_uri
107
+
108
+ source = Gem::Source.new source_uri
109
+
110
+ check_typo_squatting(source)
111
+
112
+ begin
113
+ source.load_specs :released
114
+ was_present = Gem.sources.include?(source)
115
+ Gem.sources.prepend source
116
+ Gem.configuration.write
117
+
118
+ if was_present
119
+ say "#{source_uri} moved to top of sources"
120
+ else
121
+ say "#{source_uri} added to sources"
122
+ end
123
+ rescue Gem::URI::Error, ArgumentError
124
+ say "#{source_uri} is not a URI"
125
+ terminate_interaction 1
126
+ rescue Gem::RemoteFetcher::FetchError => e
127
+ say "Error fetching #{Gem::Uri.redact(source.uri)}:\n\t#{e.message}"
128
+ terminate_interaction 1
129
+ end
130
+ end
131
+
71
132
  def check_typo_squatting(source)
72
133
  if source.typo_squatting?("rubygems.org")
73
134
  question = <<-QUESTION.chomp
@@ -128,7 +189,7 @@ yourself to use your own gem server.
128
189
  Without any arguments the sources lists your currently configured sources:
129
190
 
130
191
  $ gem sources
131
- *** CURRENT SOURCES ***
192
+ *** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***
132
193
 
133
194
  https://rubygems.org
134
195
 
@@ -147,33 +208,49 @@ Since all of these sources point to the same set of gems you only need one
147
208
  of them in your list. https://rubygems.org is recommended as it brings the
148
209
  protections of an SSL connection to gem downloads.
149
210
 
150
- To add a source use the --add argument:
211
+ To add a private gem source use the --prepend argument to insert it before
212
+ the default source. This is usually the best place for private gem sources:
151
213
 
152
- $ gem sources --add https://rubygems.org
153
- https://rubygems.org added to sources
214
+ $ gem sources --prepend https://my.private.source
215
+ https://my.private.source added to sources
154
216
 
155
217
  RubyGems will check to see if gems can be installed from the source given
156
218
  before it is added.
157
219
 
220
+ To add or move a source after all other sources, use --append:
221
+
222
+ $ gem sources --append https://rubygems.org
223
+ https://rubygems.org moved to end of sources
224
+
158
225
  To remove a source use the --remove argument:
159
226
 
160
- $ gem sources --remove https://rubygems.org/
161
- https://rubygems.org/ removed from sources
227
+ $ gem sources --remove https://my.private.source/
228
+ https://my.private.source/ removed from sources
162
229
 
163
230
  EOF
164
231
  end
165
232
 
166
233
  def list # :nodoc:
167
- say "*** CURRENT SOURCES ***"
234
+ if configured_sources
235
+ header = "*** CURRENT SOURCES ***"
236
+ list = configured_sources
237
+ else
238
+ header = "*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***"
239
+ list = Gem.sources
240
+ end
241
+
242
+ say header
168
243
  say
169
244
 
170
- Gem.sources.each do |src|
245
+ list.each do |src|
171
246
  say src
172
247
  end
173
248
  end
174
249
 
175
250
  def list? # :nodoc:
176
251
  !(options[:add] ||
252
+ options[:prepend] ||
253
+ options[:append] ||
177
254
  options[:clear_all] ||
178
255
  options[:remove] ||
179
256
  options[:update])
@@ -182,11 +259,13 @@ To remove a source use the --remove argument:
182
259
  def execute
183
260
  clear_all if options[:clear_all]
184
261
 
185
- source_uri = options[:add]
186
- add_source source_uri if source_uri
262
+ add_source options[:add] if options[:add]
263
+
264
+ prepend_source options[:prepend] if options[:prepend]
265
+
266
+ append_source options[:append] if options[:append]
187
267
 
188
- source_uri = options[:remove]
189
- remove_source source_uri if source_uri
268
+ remove_source options[:remove] if options[:remove]
190
269
 
191
270
  update if options[:update]
192
271
 
@@ -194,13 +273,21 @@ To remove a source use the --remove argument:
194
273
  end
195
274
 
196
275
  def remove_source(source_uri) # :nodoc:
197
- if Gem.sources.include? source_uri
198
- Gem.sources.delete source_uri
276
+ source = Gem::Source.new source_uri
277
+
278
+ if configured_sources&.include? source
279
+ Gem.sources.delete source
199
280
  Gem.configuration.write
200
281
 
201
- say "#{source_uri} removed from sources"
282
+ if default_sources.include?(source) && configured_sources.one?
283
+ alert_warning "Removing a default source when it is the only source has no effect. Add a different source to #{config_file_name} if you want to stop using it as a source."
284
+ else
285
+ say "#{source_uri} removed from sources"
286
+ end
287
+ elsif configured_sources
288
+ say "source #{source_uri} cannot be removed because it's not present in #{config_file_name}"
202
289
  else
203
- say "source #{source_uri} not present in cache"
290
+ say "source #{source_uri} cannot be removed because there are no configured sources in #{config_file_name}"
204
291
  end
205
292
  end
206
293
 
@@ -224,4 +311,21 @@ To remove a source use the --remove argument:
224
311
  say "*** Unable to remove #{desc} source cache ***"
225
312
  end
226
313
  end
314
+
315
+ private
316
+
317
+ def default_sources
318
+ Gem::SourceList.from(Gem.default_sources)
319
+ end
320
+
321
+ def configured_sources
322
+ return @configured_sources if defined?(@configured_sources)
323
+
324
+ configuration_sources = Gem.configuration.sources
325
+ @configured_sources = Gem::SourceList.from(configuration_sources) if configuration_sources
326
+ end
327
+
328
+ def config_file_name
329
+ Gem.configuration.config_file_name
330
+ end
227
331
  end
@@ -345,7 +345,7 @@ if you believe they were disclosed to a third party.
345
345
  require "fileutils"
346
346
  FileUtils.mkdir_p(dirname)
347
347
 
348
- permissions = 0o600 & (~File.umask)
348
+ permissions = 0o600 & ~File.umask
349
349
  File.open(credentials_path, "w", permissions) do |f|
350
350
  f.write self.class.dump_with_rubygems_yaml(config)
351
351
  end
@@ -13,7 +13,7 @@ module Gem
13
13
  # An Array of the default sources that come with RubyGems
14
14
 
15
15
  def self.default_sources
16
- %w[https://rubygems.org/]
16
+ @default_sources ||= %w[https://rubygems.org/]
17
17
  end
18
18
 
19
19
  ##
@@ -217,7 +217,7 @@ class Gem::Dependency
217
217
  # NOTE: Unlike #matches_spec? this method does not return true when the
218
218
  # version is a prerelease version unless this is a prerelease dependency.
219
219
 
220
- def match?(obj, version=nil, allow_prerelease=false)
220
+ def match?(obj, version = nil, allow_prerelease = false)
221
221
  if !version
222
222
  name = obj.name
223
223
  version = obj.version
@@ -7,14 +7,12 @@ require_relative "installer"
7
7
  require_relative "spec_fetcher"
8
8
  require_relative "user_interaction"
9
9
  require_relative "available_set"
10
- require_relative "deprecate"
11
10
 
12
11
  ##
13
12
  # Installs a gem along with all its dependencies from local and remote gems.
14
13
 
15
14
  class Gem::DependencyInstaller
16
15
  include Gem::UserInteraction
17
- extend Gem::Deprecate
18
16
 
19
17
  DEFAULT_OPTIONS = { # :nodoc:
20
18
  env_shebang: false,
@@ -28,7 +26,6 @@ class Gem::DependencyInstaller
28
26
  wrappers: true,
29
27
  build_args: nil,
30
28
  build_docs_in_background: false,
31
- install_as_default: false,
32
29
  }.freeze
33
30
 
34
31
  ##
@@ -87,7 +84,6 @@ class Gem::DependencyInstaller
87
84
  @wrappers = options[:wrappers]
88
85
  @build_args = options[:build_args]
89
86
  @build_docs_in_background = options[:build_docs_in_background]
90
- @install_as_default = options[:install_as_default]
91
87
  @dir_mode = options[:dir_mode]
92
88
  @data_mode = options[:data_mode]
93
89
  @prog_mode = options[:prog_mode]
@@ -121,78 +117,6 @@ class Gem::DependencyInstaller
121
117
  @domain == :both || @domain == :remote
122
118
  end
123
119
 
124
- ##
125
- # Returns a list of pairs of gemspecs and source_uris that match
126
- # Gem::Dependency +dep+ from both local (Dir.pwd) and remote (Gem.sources)
127
- # sources. Gems are sorted with newer gems preferred over older gems, and
128
- # local gems preferred over remote gems.
129
-
130
- def find_gems_with_sources(dep, best_only=false) # :nodoc:
131
- set = Gem::AvailableSet.new
132
-
133
- if consider_local?
134
- sl = Gem::Source::Local.new
135
-
136
- if spec = sl.find_gem(dep.name)
137
- if dep.matches_spec? spec
138
- set.add spec, sl
139
- end
140
- end
141
- end
142
-
143
- if consider_remote?
144
- begin
145
- # This is pulled from #spec_for_dependency to allow
146
- # us to filter tuples before fetching specs.
147
- tuples, errors = Gem::SpecFetcher.fetcher.search_for_dependency dep
148
-
149
- if best_only && !tuples.empty?
150
- tuples.sort! do |a,b|
151
- if b[0].version == a[0].version
152
- if b[0].platform != Gem::Platform::RUBY
153
- 1
154
- else
155
- -1
156
- end
157
- else
158
- b[0].version <=> a[0].version
159
- end
160
- end
161
- tuples = [tuples.first]
162
- end
163
-
164
- specs = []
165
- tuples.each do |tup, source|
166
- spec = source.fetch_spec(tup)
167
- rescue Gem::RemoteFetcher::FetchError => e
168
- errors << Gem::SourceFetchProblem.new(source, e)
169
- else
170
- specs << [spec, source]
171
- end
172
-
173
- if @errors
174
- @errors += errors
175
- else
176
- @errors = errors
177
- end
178
-
179
- set << specs
180
- rescue Gem::RemoteFetcher::FetchError => e
181
- # FIX if there is a problem talking to the network, we either need to always tell
182
- # the user (no really_verbose) or fail hard, not silently tell them that we just
183
- # couldn't find their requested gem.
184
- verbose do
185
- "Error fetching remote data:\t\t#{e.message}\n" \
186
- "Falling back to local-only install"
187
- end
188
- @domain = :local
189
- end
190
- end
191
-
192
- set
193
- end
194
- rubygems_deprecate :find_gems_with_sources
195
-
196
120
  def in_background(what) # :nodoc:
197
121
  fork_happened = false
198
122
  if @build_docs_in_background && Process.respond_to?(:fork)
@@ -240,7 +164,6 @@ class Gem::DependencyInstaller
240
164
  user_install: @user_install,
241
165
  wrappers: @wrappers,
242
166
  build_root: @build_root,
243
- install_as_default: @install_as_default,
244
167
  dir_mode: @dir_mode,
245
168
  data_mode: @data_mode,
246
169
  prog_mode: @prog_mode,
@@ -7,7 +7,6 @@
7
7
  #++
8
8
 
9
9
  require_relative "vendored_tsort"
10
- require_relative "deprecate"
11
10
 
12
11
  ##
13
12
  # Gem::DependencyList is used for installing and uninstalling gems in the
@@ -140,7 +139,7 @@ class Gem::DependencyList
140
139
  # If removing the gemspec creates breaks a currently ok dependency, then it
141
140
  # is NOT ok to remove the gemspec.
142
141
 
143
- def ok_to_remove?(full_name, check_dev=true)
142
+ def ok_to_remove?(full_name, check_dev = true)
144
143
  gem_to_remove = find_name full_name
145
144
 
146
145
  # If the state is inconsistent, at least don't crash
@@ -1,75 +1,75 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##
4
- # Provides 3 methods for declaring when something is going away.
5
- #
6
- # +deprecate(name, repl, year, month)+:
7
- # Indicate something may be removed on/after a certain date.
8
- #
9
- # +rubygems_deprecate(name, replacement=:none)+:
10
- # Indicate something will be removed in the next major RubyGems version,
11
- # and (optionally) a replacement for it.
12
- #
13
- # +rubygems_deprecate_command+:
14
- # Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
15
- # removed in the next RubyGems version.
16
- #
17
- # Also provides +skip_during+ for temporarily turning off deprecation warnings.
18
- # This is intended to be used in the test suite, so deprecation warnings
19
- # don't cause test failures if you need to make sure stderr is otherwise empty.
20
- #
21
- #
22
- # Example usage of +deprecate+ and +rubygems_deprecate+:
23
- #
24
- # class Legacy
25
- # def self.some_class_method
26
- # # ...
27
- # end
28
- #
29
- # def some_instance_method
30
- # # ...
31
- # end
32
- #
33
- # def some_old_method
34
- # # ...
35
- # end
36
- #
37
- # extend Gem::Deprecate
38
- # deprecate :some_instance_method, "X.z", 2011, 4
39
- # rubygems_deprecate :some_old_method, "Modern#some_new_method"
40
- #
41
- # class << self
42
- # extend Gem::Deprecate
43
- # deprecate :some_class_method, :none, 2011, 4
44
- # end
45
- # end
46
- #
47
- #
48
- # Example usage of +rubygems_deprecate_command+:
49
- #
50
- # class Gem::Commands::QueryCommand < Gem::Command
51
- # extend Gem::Deprecate
52
- # rubygems_deprecate_command
53
- #
54
- # # ...
55
- # end
56
- #
57
- #
58
- # Example usage of +skip_during+:
59
- #
60
- # class TestSomething < Gem::Testcase
61
- # def test_some_thing_with_deprecations
62
- # Gem::Deprecate.skip_during do
63
- # actual_stdout, actual_stderr = capture_output do
64
- # Gem.something_deprecated
65
- # end
66
- # assert_empty actual_stdout
67
- # assert_equal(expected, actual_stderr)
68
- # end
69
- # end
70
- # end
71
-
72
3
  module Gem
4
+ ##
5
+ # Provides 3 methods for declaring when something is going away.
6
+ #
7
+ # <tt>deprecate(name, repl, year, month)</tt>:
8
+ # Indicate something may be removed on/after a certain date.
9
+ #
10
+ # <tt>rubygems_deprecate(name, replacement=:none)</tt>:
11
+ # Indicate something will be removed in the next major RubyGems version,
12
+ # and (optionally) a replacement for it.
13
+ #
14
+ # +rubygems_deprecate_command+:
15
+ # Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
16
+ # removed in the next RubyGems version.
17
+ #
18
+ # Also provides +skip_during+ for temporarily turning off deprecation warnings.
19
+ # This is intended to be used in the test suite, so deprecation warnings
20
+ # don't cause test failures if you need to make sure stderr is otherwise empty.
21
+ #
22
+ #
23
+ # Example usage of +deprecate+ and +rubygems_deprecate+:
24
+ #
25
+ # class Legacy
26
+ # def self.some_class_method
27
+ # # ...
28
+ # end
29
+ #
30
+ # def some_instance_method
31
+ # # ...
32
+ # end
33
+ #
34
+ # def some_old_method
35
+ # # ...
36
+ # end
37
+ #
38
+ # extend Gem::Deprecate
39
+ # deprecate :some_instance_method, "X.z", 2011, 4
40
+ # rubygems_deprecate :some_old_method, "Modern#some_new_method"
41
+ #
42
+ # class << self
43
+ # extend Gem::Deprecate
44
+ # deprecate :some_class_method, :none, 2011, 4
45
+ # end
46
+ # end
47
+ #
48
+ #
49
+ # Example usage of +rubygems_deprecate_command+:
50
+ #
51
+ # class Gem::Commands::QueryCommand < Gem::Command
52
+ # extend Gem::Deprecate
53
+ # rubygems_deprecate_command
54
+ #
55
+ # # ...
56
+ # end
57
+ #
58
+ #
59
+ # Example usage of +skip_during+:
60
+ #
61
+ # class TestSomething < Gem::Testcase
62
+ # def test_some_thing_with_deprecations
63
+ # Gem::Deprecate.skip_during do
64
+ # actual_stdout, actual_stderr = capture_output do
65
+ # Gem.something_deprecated
66
+ # end
67
+ # assert_empty actual_stdout
68
+ # assert_equal(expected, actual_stderr)
69
+ # end
70
+ # end
71
+ # end
72
+
73
73
  module Deprecate
74
74
  def self.skip # :nodoc:
75
75
  @skip ||= false
@@ -126,17 +126,18 @@ module Gem
126
126
  # telling the user of +repl+ (unless +repl+ is :none) and the
127
127
  # Rubygems version that it is planned to go away.
128
128
 
129
- def rubygems_deprecate(name, replacement=:none)
129
+ def rubygems_deprecate(name, replacement = :none, version = nil)
130
130
  class_eval do
131
131
  old = "_deprecated_#{name}"
132
132
  alias_method old, name
133
133
  define_method name do |*args, &block|
134
134
  klass = is_a? Module
135
135
  target = klass ? "#{self}." : "#{self.class}#"
136
+ version ||= Gem::Deprecate.next_rubygems_major_version
136
137
  msg = [
137
138
  "NOTE: #{target}#{name} is deprecated",
138
139
  replacement == :none ? " with no replacement" : "; use #{replacement} instead",
139
- ". It will be removed in Rubygems #{Gem::Deprecate.next_rubygems_major_version}",
140
+ ". It will be removed in Rubygems #{version}",
140
141
  "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
141
142
  ]
142
143
  warn "#{msg.join}." unless Gem::Deprecate.skip
@@ -147,13 +148,14 @@ module Gem
147
148
  end
148
149
 
149
150
  # Deprecation method to deprecate Rubygems commands
150
- def rubygems_deprecate_command(version = Gem::Deprecate.next_rubygems_major_version)
151
+ def rubygems_deprecate_command(version = nil)
151
152
  class_eval do
152
153
  define_method "deprecated?" do
153
154
  true
154
155
  end
155
156
 
156
157
  define_method "deprecation_warning" do
158
+ version ||= Gem::Deprecate.next_rubygems_major_version
157
159
  msg = [
158
160
  "#{command} command is deprecated",
159
161
  ". It will be removed in Rubygems #{version}.\n",
@@ -113,7 +113,7 @@ class Gem::Doctor
113
113
  next if installed_specs.include? basename
114
114
  next if /^rubygems-\d/.match?(basename)
115
115
  next if sub_directory == "specifications" && basename == "default"
116
- next if sub_directory == "plugins" && Gem.plugin_suffix_regexp =~ (basename)
116
+ next if sub_directory == "plugins" && Gem.plugin_suffix_regexp =~ basename
117
117
 
118
118
  type = File.directory?(child) ? "directory" : "file"
119
119
 
@@ -26,7 +26,7 @@ module Gem
26
26
  # system. Instead of rescuing from this class, make sure to rescue from the
27
27
  # superclass Gem::LoadError to catch all types of load errors.
28
28
  class MissingSpecError < Gem::LoadError
29
- def initialize(name, requirement, extra_message=nil)
29
+ def initialize(name, requirement, extra_message = nil)
30
30
  @name = name
31
31
  @requirement = requirement
32
32
  @extra_message = extra_message
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "deprecate"
4
3
  require_relative "unknown_command_spell_checker"
5
4
 
6
5
  ##
@@ -21,20 +20,11 @@ class Gem::UnknownCommandError < Gem::Exception
21
20
  end
22
21
 
23
22
  def self.attach_correctable
24
- return if defined?(@attached)
23
+ return if method_defined?(:corrections)
25
24
 
26
- if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
27
- if DidYouMean.respond_to?(:correct_error)
28
- DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
29
- else
30
- DidYouMean::SPELL_CHECKERS["Gem::UnknownCommandError"] =
31
- Gem::UnknownCommandSpellChecker
32
-
33
- prepend DidYouMean::Correctable
34
- end
25
+ if defined?(DidYouMean) && DidYouMean.respond_to?(:correct_error)
26
+ DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
35
27
  end
36
-
37
- @attached = true
38
28
  end
39
29
  end
40
30
 
@@ -110,7 +100,7 @@ class Gem::SpecificGemNotFoundException < Gem::GemNotFoundException
110
100
  # and +version+. Any +errors+ encountered when attempting to find the gem
111
101
  # are also stored.
112
102
 
113
- def initialize(name, version, errors=nil)
103
+ def initialize(name, version, errors = nil)
114
104
  super "Could not find a valid gem '#{name}' (#{version}) locally or in a repository"
115
105
 
116
106
  @name = name
@@ -261,7 +251,7 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
261
251
  # Creates a new UnsatisfiableDependencyError for the unsatisfiable
262
252
  # Gem::Resolver::DependencyRequest +dep+
263
253
 
264
- def initialize(dep, platform_mismatch=nil)
254
+ def initialize(dep, platform_mismatch = nil)
265
255
  if platform_mismatch && !platform_mismatch.empty?
266
256
  plats = platform_mismatch.map {|x| x.platform.to_s }.sort.uniq
267
257
  super "Unable to resolve dependency: No match for '#{dep}' on this platform. Found: #{plats.join(", ")}"
@@ -11,6 +11,9 @@ require_relative "../user_interaction"
11
11
  class Gem::Ext::Builder
12
12
  include Gem::UserInteraction
13
13
 
14
+ class NoMakefileError < Gem::InstallError
15
+ end
16
+
14
17
  attr_accessor :build_args # :nodoc:
15
18
 
16
19
  def self.class_name
@@ -21,7 +24,8 @@ class Gem::Ext::Builder
21
24
  def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"],
22
25
  target_rbconfig: Gem.target_rbconfig)
23
26
  unless File.exist? File.join(make_dir, "Makefile")
24
- raise Gem::InstallError, "Makefile not found"
27
+ # No makefile exists, nothing to do.
28
+ raise NoMakefileError, "No Makefile found in #{make_dir}"
25
29
  end
26
30
 
27
31
  # try to find make program from Ruby configure arguments first
@@ -165,7 +169,7 @@ class Gem::Ext::Builder
165
169
  @ran_rake = true
166
170
  Gem::Ext::RakeBuilder
167
171
  when /CMakeLists.txt/ then
168
- Gem::Ext::CmakeBuilder
172
+ Gem::Ext::CmakeBuilder.new
169
173
  when /Cargo.toml/ then
170
174
  Gem::Ext::CargoBuilder.new
171
175
  else
@@ -15,7 +15,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
15
15
  end
16
16
 
17
17
  def build(extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd,
18
- target_rbconfig=Gem.target_rbconfig)
18
+ target_rbconfig = Gem.target_rbconfig)
19
19
  require "tempfile"
20
20
  require "fileutils"
21
21
 
@@ -159,7 +159,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
159
159
  def linker_args
160
160
  cc_flag = self.class.shellsplit(makefile_config("CC"))
161
161
  # Avoid to ccache like tool from Rust build
162
- # see https://github.com/rubygems/rubygems/pull/8521#issuecomment-2689854359
162
+ # see https://github.com/ruby/rubygems/pull/8521#issuecomment-2689854359
163
163
  # ex. CC="ccache gcc" or CC="sccache clang --any --args"
164
164
  cc_flag.shift if cc_flag.size >= 2 && !cc_flag[1].start_with?("-")
165
165
  linker = cc_flag.shift