bundler 2.2.3 → 2.3.5

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 (183) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +503 -7
  3. data/README.md +1 -1
  4. data/bundler.gemspec +2 -3
  5. data/exe/bundle +7 -8
  6. data/lib/bundler/.document +1 -0
  7. data/lib/bundler/build_metadata.rb +2 -2
  8. data/lib/bundler/cli/cache.rb +2 -1
  9. data/lib/bundler/cli/check.rb +4 -2
  10. data/lib/bundler/cli/common.rb +15 -2
  11. data/lib/bundler/cli/doctor.rb +15 -4
  12. data/lib/bundler/cli/exec.rb +1 -6
  13. data/lib/bundler/cli/gem.rb +132 -24
  14. data/lib/bundler/cli/info.rb +16 -4
  15. data/lib/bundler/cli/install.rb +12 -27
  16. data/lib/bundler/cli/issue.rb +4 -3
  17. data/lib/bundler/cli/list.rb +7 -1
  18. data/lib/bundler/cli/lock.rb +5 -1
  19. data/lib/bundler/cli/open.rb +1 -2
  20. data/lib/bundler/cli/outdated.rb +10 -11
  21. data/lib/bundler/cli/remove.rb +1 -2
  22. data/lib/bundler/cli/update.rb +17 -8
  23. data/lib/bundler/cli.rb +44 -60
  24. data/lib/bundler/compact_index_client/cache.rb +0 -9
  25. data/lib/bundler/compact_index_client/updater.rb +10 -19
  26. data/lib/bundler/compact_index_client.rb +2 -8
  27. data/lib/bundler/current_ruby.rb +5 -4
  28. data/lib/bundler/definition.rb +158 -316
  29. data/lib/bundler/dep_proxy.rb +15 -8
  30. data/lib/bundler/dependency.rb +5 -7
  31. data/lib/bundler/digest.rb +71 -0
  32. data/lib/bundler/dsl.rb +67 -66
  33. data/lib/bundler/endpoint_specification.rb +21 -11
  34. data/lib/bundler/environment_preserver.rb +4 -1
  35. data/lib/bundler/errors.rb +19 -3
  36. data/lib/bundler/feature_flag.rb +0 -5
  37. data/lib/bundler/fetcher/compact_index.rb +10 -15
  38. data/lib/bundler/fetcher/downloader.rb +9 -6
  39. data/lib/bundler/fetcher/index.rb +0 -27
  40. data/lib/bundler/fetcher.rb +10 -17
  41. data/lib/bundler/friendly_errors.rb +5 -32
  42. data/lib/bundler/gem_helper.rb +28 -21
  43. data/lib/bundler/gem_version_promoter.rb +2 -2
  44. data/lib/bundler/index.rb +8 -12
  45. data/lib/bundler/injector.rb +12 -3
  46. data/lib/bundler/inline.rb +2 -1
  47. data/lib/bundler/installer/gem_installer.rb +4 -22
  48. data/lib/bundler/installer/parallel_installer.rb +36 -15
  49. data/lib/bundler/installer/standalone.rb +29 -9
  50. data/lib/bundler/installer.rb +8 -34
  51. data/lib/bundler/lazy_specification.rb +32 -20
  52. data/lib/bundler/lockfile_generator.rb +1 -1
  53. data/lib/bundler/lockfile_parser.rb +16 -45
  54. data/{man → lib/bundler/man}/bundle-add.1 +10 -2
  55. data/lib/bundler/man/bundle-add.1.ronn +7 -1
  56. data/{man → lib/bundler/man}/bundle-binstubs.1 +1 -1
  57. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  58. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  59. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  60. data/{man → lib/bundler/man}/bundle-config.1 +27 -19
  61. data/lib/bundler/man/bundle-config.1.ronn +33 -25
  62. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  63. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  64. data/{man → lib/bundler/man}/bundle-gem.1 +14 -1
  65. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  66. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  67. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  68. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  69. data/{man → lib/bundler/man}/bundle-install.1 +2 -2
  70. data/lib/bundler/man/bundle-install.1.ronn +2 -2
  71. data/{man → lib/bundler/man}/bundle-list.1 +1 -1
  72. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  73. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  74. data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
  75. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  76. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  77. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  78. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  79. data/{man → lib/bundler/man}/bundle-update.1 +5 -5
  80. data/lib/bundler/man/bundle-update.1.ronn +5 -4
  81. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  82. data/{man → lib/bundler/man}/bundle.1 +1 -1
  83. data/{man → lib/bundler/man}/gemfile.5 +28 -2
  84. data/lib/bundler/man/gemfile.5.ronn +9 -1
  85. data/{man → lib/bundler/man}/index.txt +0 -0
  86. data/lib/bundler/plugin/api/source.rb +22 -0
  87. data/lib/bundler/plugin/index.rb +4 -1
  88. data/lib/bundler/plugin/installer.rb +10 -10
  89. data/lib/bundler/plugin/source_list.rb +4 -0
  90. data/lib/bundler/plugin.rb +28 -8
  91. data/lib/bundler/process_lock.rb +1 -1
  92. data/lib/bundler/psyched_yaml.rb +1 -13
  93. data/lib/bundler/resolver/spec_group.rb +36 -48
  94. data/lib/bundler/resolver.rb +97 -151
  95. data/lib/bundler/retry.rb +1 -1
  96. data/lib/bundler/ruby_version.rb +1 -1
  97. data/lib/bundler/rubygems_ext.rb +46 -8
  98. data/lib/bundler/rubygems_gem_installer.rb +68 -1
  99. data/lib/bundler/rubygems_integration.rb +43 -60
  100. data/lib/bundler/runtime.rb +18 -11
  101. data/lib/bundler/self_manager.rb +168 -0
  102. data/lib/bundler/settings.rb +97 -21
  103. data/lib/bundler/setup.rb +2 -2
  104. data/lib/bundler/shared_helpers.rb +6 -21
  105. data/lib/bundler/source/git/git_proxy.rb +60 -53
  106. data/lib/bundler/source/git.rb +38 -18
  107. data/lib/bundler/source/metadata.rb +1 -5
  108. data/lib/bundler/source/path/installer.rb +3 -1
  109. data/lib/bundler/source/path.rb +3 -1
  110. data/lib/bundler/source/rubygems.rb +113 -100
  111. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  112. data/lib/bundler/source.rb +21 -0
  113. data/lib/bundler/source_list.rb +100 -62
  114. data/lib/bundler/source_map.rb +58 -0
  115. data/lib/bundler/spec_set.rb +21 -34
  116. data/lib/bundler/stub_specification.rb +8 -0
  117. data/lib/bundler/templates/Executable.bundler +7 -7
  118. data/lib/bundler/templates/Gemfile +0 -2
  119. data/lib/bundler/templates/gems.rb +0 -3
  120. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  121. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  122. data/lib/bundler/templates/newgem/README.md.tt +5 -3
  123. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  124. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +15 -6
  125. data/lib/bundler/templates/newgem/newgem.gemspec.tt +18 -16
  126. data/lib/bundler/templates/newgem/rubocop.yml.tt +3 -0
  127. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  128. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  129. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  130. data/lib/bundler/ui/shell.rb +1 -1
  131. data/lib/bundler/vendor/.document +1 -0
  132. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  133. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  134. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  135. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  136. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  137. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  138. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  139. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  140. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  141. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -3
  142. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +2 -2
  143. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  144. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +11 -7
  145. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  146. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  147. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +9 -7
  148. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  149. data/lib/bundler/vendor/thor/lib/thor/actions.rb +7 -3
  150. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  151. data/lib/bundler/vendor/thor/lib/thor/error.rb +10 -5
  152. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  153. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +28 -9
  154. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +27 -6
  155. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  156. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  157. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  158. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  159. data/lib/bundler/vendor/thor/lib/thor.rb +5 -6
  160. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  161. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  162. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  163. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  164. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  165. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  166. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  167. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  168. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  169. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  170. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  171. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  172. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  173. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  174. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  175. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  176. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  177. data/lib/bundler/vendored_tsort.rb +4 -0
  178. data/lib/bundler/version.rb +1 -1
  179. data/lib/bundler/worker.rb +19 -4
  180. data/lib/bundler.rb +29 -33
  181. metadata +54 -35
  182. data/lib/bundler/gemdeps.rb +0 -29
  183. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -9,7 +9,7 @@ module Bundler
9
9
  end
10
10
 
11
11
  def run
12
- Bundler.ui.level = "error" if options[:quiet]
12
+ Bundler.ui.level = "warn" if options[:quiet]
13
13
  Bundler.settings.set_command_option_if_given :path, options[:path]
14
14
  Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
15
15
 
@@ -30,6 +30,7 @@ module Bundler
30
30
  require_relative "install"
31
31
  options = self.options.dup
32
32
  options["local"] = false if Bundler.settings[:cache_all_platforms]
33
+ options["no-cache"] = true
33
34
  Bundler::CLI::Install.new(options).run
34
35
  end
35
36
 
@@ -11,9 +11,11 @@ module Bundler
11
11
  def run
12
12
  Bundler.settings.set_command_option_if_given :path, options[:path]
13
13
 
14
+ definition = Bundler.definition
15
+ definition.validate_runtime!
16
+
14
17
  begin
15
- definition = Bundler.definition
16
- definition.validate_runtime!
18
+ definition.resolve_only_locally!
17
19
  not_installed = definition.missing_specs
18
20
  rescue GemNotFound, VersionConflict
19
21
  Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
@@ -36,10 +36,15 @@ module Bundler
36
36
  def self.without_groups_message(command)
37
37
  command_in_past_tense = command == :install ? "installed" : "updated"
38
38
  groups = Bundler.settings[:without]
39
+ "Gems in the #{verbalize_groups(groups)} were not #{command_in_past_tense}."
40
+ end
41
+
42
+ def self.verbalize_groups(groups)
43
+ groups.map!{|g| "'#{g}'" }
39
44
  group_list = [groups[0...-1].join(", "), groups[-1..-1]].
40
45
  reject {|s| s.to_s.empty? }.join(" and ")
41
46
  group_str = groups.size == 1 ? "group" : "groups"
42
- "Gems in the #{group_str} #{group_list} were not #{command_in_past_tense}."
47
+ "#{group_str} #{group_list}"
43
48
  end
44
49
 
45
50
  def self.select_spec(name, regex_match = nil)
@@ -53,7 +58,13 @@ module Bundler
53
58
 
54
59
  case specs.count
55
60
  when 0
56
- raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
61
+ dep_in_other_group = Bundler.definition.current_dependencies.find {|dep|dep.name == name }
62
+
63
+ if dep_in_other_group
64
+ raise GemNotFound, "Could not find gem '#{name}', because it's in the #{verbalize_groups(dep_in_other_group.groups)}, configured to be ignored."
65
+ else
66
+ raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
67
+ end
57
68
  when 1
58
69
  specs.first
59
70
  else
@@ -83,6 +94,8 @@ module Bundler
83
94
  end
84
95
 
85
96
  def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
97
+ return unless locked_gems
98
+
86
99
  locked_names = locked_gems.specs.map(&:name).uniq
87
100
  names.-(locked_names).each do |g|
88
101
  raise GemNotFound, gem_not_found_message(g, locked_names)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rbconfig"
4
+ require "shellwords"
4
5
 
5
6
  module Bundler
6
7
  class CLI::Doctor
@@ -22,14 +23,14 @@ module Bundler
22
23
  end
23
24
 
24
25
  def dylibs_darwin(path)
25
- output = `/usr/bin/otool -L "#{path}"`.chomp
26
+ output = `/usr/bin/otool -L #{path.shellescape}`.chomp
26
27
  dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
27
28
  # ignore @rpath and friends
28
29
  dylibs.reject {|dylib| dylib.start_with? "@" }
29
30
  end
30
31
 
31
32
  def dylibs_ldd(path)
32
- output = `/usr/bin/ldd "#{path}"`.chomp
33
+ output = `/usr/bin/ldd #{path.shellescape}`.chomp
33
34
  output.split("\n").map do |l|
34
35
  match = l.match(LDD_REGEX)
35
36
  next if match.nil?
@@ -61,7 +62,7 @@ module Bundler
61
62
  end
62
63
 
63
64
  def run
64
- Bundler.ui.level = "error" if options[:quiet]
65
+ Bundler.ui.level = "warn" if options[:quiet]
65
66
  Bundler.settings.validate!
66
67
  check!
67
68
 
@@ -100,8 +101,11 @@ module Bundler
100
101
  files_not_readable_or_writable = []
101
102
  files_not_rw_and_owned_by_different_user = []
102
103
  files_not_owned_by_current_user_but_still_rw = []
104
+ broken_symlinks = []
103
105
  Find.find(Bundler.bundle_path.to_s).each do |f|
104
- if !File.writable?(f) || !File.readable?(f)
106
+ if !File.exist?(f)
107
+ broken_symlinks << f
108
+ elsif !File.writable?(f) || !File.readable?(f)
105
109
  if File.stat(f).uid != Process.uid
106
110
  files_not_rw_and_owned_by_different_user << f
107
111
  else
@@ -113,6 +117,13 @@ module Bundler
113
117
  end
114
118
 
115
119
  ok = true
120
+
121
+ if broken_symlinks.any?
122
+ Bundler.ui.warn "Broken links exist in the Bundler home. Please report them to the offending gem's upstream repo. These files are:\n - #{broken_symlinks.join("\n - ")}"
123
+
124
+ ok = false
125
+ end
126
+
116
127
  if files_not_owned_by_current_user_but_still_rw.any?
117
128
  Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
118
129
  "user, but are still readable/writable. These files are:\n - #{files_not_owned_by_current_user_but_still_rw.join("\n - ")}"
@@ -12,12 +12,7 @@ module Bundler
12
12
  @options = options
13
13
  @cmd = args.shift
14
14
  @args = args
15
-
16
- if !Bundler.current_ruby.jruby?
17
- @args << { :close_others => !options.keep_file_descriptors? }
18
- elsif options.keep_file_descriptors?
19
- Bundler.ui.warn "Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec."
20
- end
15
+ @args << { :close_others => !options.keep_file_descriptors? } unless Bundler.current_ruby.jruby?
21
16
  end
22
17
 
23
18
  def run
@@ -39,11 +39,19 @@ module Bundler
39
39
  constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
40
40
  constant_array = constant_name.split("::")
41
41
 
42
- git_installed = Bundler.git_present?
42
+ use_git = Bundler.git_present? && options[:git]
43
43
 
44
- git_author_name = git_installed ? `git config user.name`.chomp : ""
45
- github_username = git_installed ? `git config github.user`.chomp : ""
46
- git_user_email = git_installed ? `git config user.email`.chomp : ""
44
+ git_author_name = use_git ? `git config user.name`.chomp : ""
45
+ git_username = use_git ? `git config github.user`.chomp : ""
46
+ git_user_email = use_git ? `git config user.email`.chomp : ""
47
+
48
+ github_username = if options[:github_username].nil?
49
+ git_username
50
+ elsif options[:github_username] == false
51
+ ""
52
+ else
53
+ options[:github_username]
54
+ end
47
55
 
48
56
  config = {
49
57
  :name => name,
@@ -58,7 +66,9 @@ module Bundler
58
66
  :ext => options[:ext],
59
67
  :exe => options[:exe],
60
68
  :bundler_version => bundler_dependency_version,
69
+ :git => use_git,
61
70
  :github_username => github_username.empty? ? "[USERNAME]" : github_username,
71
+ :required_ruby_version => required_ruby_version,
62
72
  }
63
73
  ensure_safe_gem_name(name, constant_array)
64
74
 
@@ -66,6 +76,7 @@ module Bundler
66
76
  "#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
67
77
  "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
68
78
  "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
79
+ "sig/newgem.rbs.tt" => "sig/#{namespaced_path}.rbs",
69
80
  "newgem.gemspec.tt" => "#{name}.gemspec",
70
81
  "Rakefile.tt" => "Rakefile",
71
82
  "README.md.tt" => "README.md",
@@ -78,7 +89,7 @@ module Bundler
78
89
  bin/setup
79
90
  ]
80
91
 
81
- templates.merge!("gitignore.tt" => ".gitignore") if Bundler.git_present?
92
+ templates.merge!("gitignore.tt" => ".gitignore") if use_git
82
93
 
83
94
  if test_framework = ask_and_set_test_framework
84
95
  config[:test] = test_framework
@@ -95,7 +106,7 @@ module Bundler
95
106
  when "minitest"
96
107
  templates.merge!(
97
108
  "test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
98
- "test/minitest/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
109
+ "test/minitest/test_newgem.rb.tt" => "test/test_#{namespaced_path}.rb"
99
110
  )
100
111
  config[:test_task] = :test
101
112
  when "test-unit"
@@ -141,14 +152,28 @@ module Bundler
141
152
  templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
142
153
  end
143
154
 
144
- if ask_and_set(:rubocop, "Do you want to add rubocop as a dependency for gems you generate?",
145
- "RuboCop is a static code analyzer that has out-of-the-box rules for many " \
146
- "of the guidelines in the community style guide. " \
147
- "For more information, see the RuboCop docs (https://docs.rubocop.org/en/stable/) " \
148
- "and the Ruby Style Guides (https://github.com/rubocop-hq/ruby-style-guide).")
149
- config[:rubocop] = true
155
+ if ask_and_set(:changelog, "Do you want to include a changelog?",
156
+ "A changelog is a file which contains a curated, chronologically ordered list of notable " \
157
+ "changes for each version of a project. To make it easier for users and contributors to" \
158
+ " see precisely what notable changes have been made between each release (or version) of" \
159
+ " the project. Whether consumers or developers, the end users of software are" \
160
+ " human beings who care about what's in the software. When the software changes, people " \
161
+ "want to know why and how. see https://keepachangelog.com")
162
+ config[:changelog] = true
163
+ Bundler.ui.info "Changelog enabled in config"
164
+ templates.merge!("CHANGELOG.md.tt" => "CHANGELOG.md")
165
+ end
166
+
167
+ config[:linter] = ask_and_set_linter
168
+ case config[:linter]
169
+ when "rubocop"
170
+ config[:linter_version] = rubocop_version
150
171
  Bundler.ui.info "RuboCop enabled in config"
151
172
  templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
173
+ when "standard"
174
+ config[:linter_version] = standard_version
175
+ Bundler.ui.info "Standard enabled in config"
176
+ templates.merge!("standard.yml.tt" => ".standard.yml")
152
177
  end
153
178
 
154
179
  templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe]
@@ -161,24 +186,32 @@ module Bundler
161
186
  )
162
187
  end
163
188
 
189
+ if target.exist? && !target.directory?
190
+ Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`."
191
+ exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError]
192
+ end
193
+
194
+ if use_git
195
+ Bundler.ui.info "Initializing git repo in #{target}"
196
+ require "shellwords"
197
+ `git init #{target.to_s.shellescape}`
198
+
199
+ config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp
200
+ end
201
+
164
202
  templates.each do |src, dst|
165
203
  destination = target.join(dst)
166
- SharedHelpers.filesystem_access(destination) do
167
- thor.template("newgem/#{src}", destination, config)
168
- end
204
+ thor.template("newgem/#{src}", destination, config)
169
205
  end
170
206
 
171
207
  executables.each do |file|
172
- SharedHelpers.filesystem_access(target.join(file)) do |path|
173
- executable = (path.stat.mode | 0o111)
174
- path.chmod(executable)
175
- end
208
+ path = target.join(file)
209
+ executable = (path.stat.mode | 0o111)
210
+ path.chmod(executable)
176
211
  end
177
212
 
178
- if Bundler.git_present? && options[:git]
179
- Bundler.ui.info "Initializing git repo in #{target}"
213
+ if use_git
180
214
  Dir.chdir(target) do
181
- `git init`
182
215
  `git add .`
183
216
  end
184
217
  end
@@ -188,8 +221,6 @@ module Bundler
188
221
 
189
222
  Bundler.ui.info "Gem '#{name}' was successfully created. " \
190
223
  "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
191
- rescue Errno::EEXIST => e
192
- raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.")
193
224
  end
194
225
 
195
226
  private
@@ -288,6 +319,58 @@ module Bundler
288
319
  ci_template
289
320
  end
290
321
 
322
+ def ask_and_set_linter
323
+ linter_template = options[:linter] || Bundler.settings["gem.linter"]
324
+ linter_template = deprecated_rubocop_option if linter_template.nil?
325
+
326
+ if linter_template.to_s.empty?
327
+ Bundler.ui.confirm "Do you want to add a code linter and formatter to your gem? " \
328
+ "Supported Linters:\n" \
329
+ "* RuboCop: https://rubocop.org\n" \
330
+ "* Standard: https://github.com/testdouble/standard\n" \
331
+ "\n"
332
+ Bundler.ui.info hint_text("linter")
333
+
334
+ result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):"
335
+ if result =~ /rubocop|standard/
336
+ linter_template = result
337
+ else
338
+ linter_template = false
339
+ end
340
+ end
341
+
342
+ if Bundler.settings["gem.linter"].nil?
343
+ Bundler.settings.set_global("gem.linter", linter_template)
344
+ end
345
+
346
+ # Once gem.linter safely set, unset the deprecated gem.rubocop
347
+ unless Bundler.settings["gem.rubocop"].nil?
348
+ Bundler.settings.set_global("gem.rubocop", nil)
349
+ end
350
+
351
+ if options[:linter] == Bundler.settings["gem.linter"]
352
+ Bundler.ui.info "#{options[:linter]} is already configured, ignoring --linter flag."
353
+ end
354
+
355
+ linter_template
356
+ end
357
+
358
+ def deprecated_rubocop_option
359
+ if !options[:rubocop].nil?
360
+ if options[:rubocop]
361
+ Bundler::SharedHelpers.major_deprecation 2, "--rubocop is deprecated, use --linter=rubocop"
362
+ "rubocop"
363
+ else
364
+ Bundler::SharedHelpers.major_deprecation 2, "--no-rubocop is deprecated, use --linter"
365
+ false
366
+ end
367
+ elsif !Bundler.settings["gem.rubocop"].nil?
368
+ Bundler::SharedHelpers.major_deprecation 2,
369
+ "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
370
+ Bundler.settings["gem.rubocop"] ? "rubocop" : false
371
+ end
372
+ end
373
+
291
374
  def bundler_dependency_version
292
375
  v = Gem::Version.new(Bundler::VERSION)
293
376
  req = v.segments[0..1]
@@ -321,5 +404,30 @@ module Bundler
321
404
  def open_editor(editor, file)
322
405
  thor.run(%(#{editor} "#{file}"))
323
406
  end
407
+
408
+ def required_ruby_version
409
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "2.3.0"
410
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "2.4.0"
411
+ elsif Gem.ruby_version < Gem::Version.new("2.6.a") then "2.5.0"
412
+ else
413
+ "2.6.0"
414
+ end
415
+ end
416
+
417
+ def rubocop_version
418
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.81.0"
419
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.12"
420
+ else
421
+ "1.21"
422
+ end
423
+ end
424
+
425
+ def standard_version
426
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.2.5"
427
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.0"
428
+ else
429
+ "1.3"
430
+ end
431
+ end
324
432
  end
325
433
  end
@@ -18,6 +18,7 @@ module Bundler
18
18
 
19
19
  if spec
20
20
  return print_gem_path(spec) if @options[:path]
21
+ return print_gem_version(spec) if @options[:version]
21
22
  print_gem_info(spec)
22
23
  end
23
24
  end
@@ -39,13 +40,18 @@ module Bundler
39
40
  raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
40
41
  end
41
42
 
43
+ def print_gem_version(spec)
44
+ Bundler.ui.info spec.version.to_s
45
+ end
46
+
42
47
  def print_gem_path(spec)
43
- if spec.name == "bundler"
48
+ name = spec.name
49
+ if name == "bundler"
44
50
  path = File.expand_path("../../../..", __FILE__)
45
51
  else
46
52
  path = spec.full_gem_path
47
- unless File.directory?(path)
48
- return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}"
53
+ if spec.deleted_gem?
54
+ return Bundler.ui.warn "The gem #{name} has been deleted. It was installed at: #{path}"
49
55
  end
50
56
  end
51
57
 
@@ -54,8 +60,9 @@ module Bundler
54
60
 
55
61
  def print_gem_info(spec)
56
62
  metadata = spec.metadata
63
+ name = spec.name
57
64
  gem_info = String.new
58
- gem_info << " * #{spec.name} (#{spec.version}#{spec.git_version})\n"
65
+ gem_info << " * #{name} (#{spec.version}#{spec.git_version})\n"
59
66
  gem_info << "\tSummary: #{spec.summary}\n" if spec.summary
60
67
  gem_info << "\tHomepage: #{spec.homepage}\n" if spec.homepage
61
68
  gem_info << "\tDocumentation: #{metadata["documentation_uri"]}\n" if metadata.key?("documentation_uri")
@@ -67,6 +74,11 @@ module Bundler
67
74
  gem_info << "\tMailing List: #{metadata["mailing_list_uri"]}\n" if metadata.key?("mailing_list_uri")
68
75
  gem_info << "\tPath: #{spec.full_gem_path}\n"
69
76
  gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem?
77
+
78
+ if name != "bundler" && spec.deleted_gem?
79
+ return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}"
80
+ end
81
+
70
82
  Bundler.ui.info gem_info
71
83
  end
72
84
  end
@@ -8,10 +8,12 @@ module Bundler
8
8
  end
9
9
 
10
10
  def run
11
- Bundler.ui.level = "error" if options[:quiet]
11
+ Bundler.ui.level = "warn" if options[:quiet]
12
12
 
13
13
  warn_if_root
14
14
 
15
+ Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
16
+
15
17
  Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
16
18
 
17
19
  # Disable color in deployment mode
@@ -33,12 +35,8 @@ module Bundler
33
35
 
34
36
  options[:local] = true if Bundler.app_cache.exist?
35
37
 
36
- if Bundler.feature_flag.deployment_means_frozen?
37
- Bundler.settings.set_command_option :deployment, true
38
- else
39
- Bundler.settings.set_command_option :deployment, true if options[:deployment]
40
- Bundler.settings.set_command_option :frozen, true if options[:frozen]
41
- end
38
+ Bundler.settings.set_command_option :deployment, true if options[:deployment]
39
+ Bundler.settings.set_command_option :frozen, true if options[:frozen]
42
40
  end
43
41
 
44
42
  # When install is called with --no-deployment, disable deployment mode
@@ -62,7 +60,10 @@ module Bundler
62
60
  definition.validate_runtime!
63
61
 
64
62
  installer = Installer.install(Bundler.root, definition, options)
65
- Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
63
+
64
+ Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
65
+ Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
66
+ end
66
67
 
67
68
  Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
68
69
  Bundler::CLI::Common.output_without_groups_message(:install)
@@ -84,28 +85,15 @@ module Bundler
84
85
  end
85
86
 
86
87
  Bundler::CLI::Common.output_fund_metadata_summary
87
- rescue GemNotFound, VersionConflict => e
88
- if options[:local] && Bundler.app_cache.exist?
89
- Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
90
- end
91
-
92
- unless Bundler.definition.has_rubygems_remotes?
93
- Bundler.ui.warn <<-WARN, :wrap => true
94
- Your Gemfile has no gem server sources. If you need gems that are \
95
- not already on your machine, add a line like this to your Gemfile:
96
- source 'https://rubygems.org'
97
- WARN
98
- end
99
- raise e
100
- rescue Gem::InvalidSpecificationException => e
88
+ rescue Gem::InvalidSpecificationException
101
89
  Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed."
102
- raise e
90
+ raise
103
91
  end
104
92
 
105
93
  private
106
94
 
107
95
  def warn_if_root
108
- return if Bundler.settings[:silence_root_warning] || Bundler::WINDOWS || !Process.uid.zero?
96
+ return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero?
109
97
  Bundler.ui.warn "Don't run Bundler as root. Bundler can ask for sudo " \
110
98
  "if it is needed, and installing your bundle as root will break this " \
111
99
  "application for all non-root users on this machine.", :wrap => true
@@ -177,9 +165,6 @@ module Bundler
177
165
 
178
166
  def normalize_settings
179
167
  Bundler.settings.set_command_option :path, nil if options[:system]
180
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
181
- Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil?
182
- end
183
168
  Bundler.settings.set_command_option_if_given :path, options[:path]
184
169
  Bundler.settings.temporary(:path_relative_to_cwd => false) do
185
170
  Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
@@ -20,9 +20,10 @@ module Bundler
20
20
 
21
21
  Hopefully the troubleshooting steps above resolved your problem! If things
22
22
  still aren't working the way you expect them to, please let us know so
23
- that we can diagnose and help fix the problem you're having. Please
24
- view the Filing Issues guide for more information:
25
- https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/ISSUES.md
23
+ that we can diagnose and help fix the problem you're having, by filling
24
+ in the new issue form located at
25
+ https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
26
+ and copy and pasting the information below.
26
27
 
27
28
  EOS
28
29
 
@@ -16,7 +16,13 @@ module Bundler
16
16
  specs = if @only_group.any? || @without_group.any?
17
17
  filtered_specs_by_groups
18
18
  else
19
- Bundler.load.specs
19
+ begin
20
+ Bundler.load.specs
21
+ rescue GemNotFound => e
22
+ Bundler.ui.error e.message
23
+ Bundler.ui.warn "Install missing gems with `bundle install`."
24
+ exit 1
25
+ end
20
26
  end.reject {|s| s.name == "bundler" }.sort_by(&:name)
21
27
 
22
28
  return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
@@ -21,9 +21,13 @@ module Bundler
21
21
  Bundler::Fetcher.disable_endpoint = options["full-index"]
22
22
 
23
23
  update = options[:update]
24
+ conservative = options[:conservative]
25
+
24
26
  if update.is_a?(Array) # unlocking specific gems
25
27
  Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
26
- update = { :gems => update, :lock_shared_dependencies => options[:conservative] }
28
+ update = { :gems => update, :conservative => conservative }
29
+ elsif update
30
+ update = { :conservative => conservative } if conservative
27
31
  end
28
32
  definition = Bundler.definition(update)
29
33
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class CLI::Open
7
5
  attr_reader :options, :name
@@ -19,6 +17,7 @@ module Bundler
19
17
  else
20
18
  path = spec.full_gem_path
21
19
  Dir.chdir(path) do
20
+ require "shellwords"
22
21
  command = Shellwords.split(editor) + [path]
23
22
  Bundler.with_original_env do
24
23
  system(*command)
@@ -72,7 +72,7 @@ module Bundler
72
72
  gemfile_specs + dependency_specs
73
73
  end
74
74
 
75
- specs.sort_by(&:name).each do |current_spec|
75
+ specs.sort_by(&:name).uniq(&:name).each do |current_spec|
76
76
  next unless gems.empty? || gems.include?(current_spec.name)
77
77
 
78
78
  active_spec = retrieve_active_spec(definition, current_spec)
@@ -146,17 +146,16 @@ module Bundler
146
146
  end
147
147
 
148
148
  def retrieve_active_spec(definition, current_spec)
149
- if strict
150
- active_spec = definition.find_resolved_spec(current_spec)
151
- else
152
- active_specs = definition.find_indexed_specs(current_spec)
153
- if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
154
- active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
155
- end
156
- active_spec = active_specs.last
157
- end
149
+ active_spec = definition.resolve.find_by_name_and_platform(current_spec.name, current_spec.platform)
150
+ return unless active_spec
158
151
 
159
- active_spec
152
+ return active_spec if strict
153
+
154
+ active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
155
+ if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
156
+ active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
157
+ end
158
+ active_specs.last
160
159
  end
161
160
 
162
161
  def print_gems(gems_list)
@@ -11,8 +11,7 @@ module Bundler
11
11
  raise InvalidOption, "Please specify gems to remove." if @gems.empty?
12
12
 
13
13
  Injector.remove(@gems, {})
14
-
15
- Installer.install(Bundler.root, Bundler.definition) if @options["install"]
14
+ Installer.install(Bundler.root, Bundler.definition)
16
15
  end
17
16
  end
18
17
  end