diff options
Diffstat (limited to 'lib')
30 files changed, 167 insertions, 59 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 981c885f6f..d6e69afddf 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -504,8 +504,8 @@ module Bundler By default, setting a configuration value sets it for all projects on the machine. - If a global setting is superceded by local configuration, this command - will show the current value, as well as any superceded values and + If a global setting is superseded by local configuration, this command + will show the current value, as well as any superseded values and where they were specified. D require_relative "cli/config" diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index 32d952fb72..ba259143b7 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -94,6 +94,8 @@ module Bundler end def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems) + return unless locked_gems + locked_names = locked_gems.specs.map(&:name).uniq names.-(locked_names).each do |g| raise GemNotFound, gem_not_found_message(g, locked_names) diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb index 9e0180fac7..06486f98cb 100644 --- a/lib/bundler/compact_index_client/updater.rb +++ b/lib/bundler/compact_index_client/updater.rb @@ -50,16 +50,20 @@ module Bundler content = response.body - SharedHelpers.filesystem_access(local_temp_path) do + etag = (response["ETag"] || "").gsub(%r{\AW/}, "") + correct_response = SharedHelpers.filesystem_access(local_temp_path) do if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero? local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) } + + etag_for(local_temp_path) == etag else local_temp_path.open("wb") {|f| f << content } + + etag.length.zero? || etag_for(local_temp_path) == etag end end - etag = (response["ETag"] || "").gsub(%r{\AW/}, "") - if etag.length.zero? || etag_for(local_temp_path) == etag + if correct_response SharedHelpers.filesystem_access(local_path) do FileUtils.mv(local_temp_path, local_path) end @@ -92,11 +96,11 @@ module Bundler def checksum_for_file(path) return nil unless path.file? - # This must use IO.read instead of Digest.file().hexdigest + # This must use File.read instead of Digest.file().hexdigest # because we need to preserve \n line endings on windows when calculating # the checksum SharedHelpers.filesystem_access(path, :read) do - SharedHelpers.digest(:MD5).hexdigest(IO.read(path)) + SharedHelpers.digest(:MD5).hexdigest(File.read(path)) end end end diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb index c132e8ecc0..b8c7cada1c 100644 --- a/lib/bundler/current_ruby.rb +++ b/lib/bundler/current_ruby.rb @@ -20,6 +20,7 @@ module Bundler 2.5 2.6 2.7 + 3.0 ].freeze KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 562f50c3fb..d4d3ce5a2d 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -161,16 +161,14 @@ module Bundler end def resolve_with_cache! - raise "Specs already loaded" if @specs sources.cached! - specs + resolve end def resolve_remotely! - return if @specs @remote = true sources.remote! - specs + resolve end # For given dependency list returns a SpecSet with Gemspec of all the required diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 0c81c54740..2bbe53aa25 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -47,7 +47,8 @@ module Bundler remote_uri = filter_uri(remote_uri) super "Authentication is required for #{remote_uri}.\n" \ "Please supply credentials for this source. You can do this by running:\n" \ - " bundle config set --global #{remote_uri} username:password" + "`bundle config set --global #{remote_uri} username:password`\n" \ + "or by storing the credentials in the `#{Settings.key_for(remote_uri)}` environment variable" end end # This error is raised if HTTP authentication is provided, but incorrect. diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb index a2289aaaae..5d30333158 100644 --- a/lib/bundler/fetcher/downloader.rb +++ b/lib/bundler/fetcher/downloader.rb @@ -14,8 +14,10 @@ module Bundler def fetch(uri, headers = {}, counter = 0) raise HTTPError, "Too many redirects" if counter >= redirect_limit + filtered_uri = URICredentialsFilter.credential_filtered_uri(uri) + response = request(uri, headers) - Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}") + Bundler.ui.debug("HTTP #{response.code} #{response.message} #{filtered_uri}") case response when Net::HTTPSuccess, Net::HTTPNotModified @@ -40,7 +42,7 @@ module Bundler raise BadAuthenticationError, uri.host if uri.userinfo raise AuthenticationRequiredError, uri.host when Net::HTTPNotFound - raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}" + raise FallbackError, "Net::HTTPNotFound: #{filtered_uri}" else raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}" end @@ -49,7 +51,9 @@ module Bundler def request(uri, headers) validate_uri_scheme!(uri) - Bundler.ui.debug "HTTP GET #{uri}" + filtered_uri = URICredentialsFilter.credential_filtered_uri(uri) + + Bundler.ui.debug "HTTP GET #{filtered_uri}" req = Net::HTTP::Get.new uri.request_uri, headers if uri.user user = CGI.unescape(uri.user) @@ -69,7 +73,7 @@ module Bundler raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \ "connection and try again." else - raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" \ + raise HTTPError, "Network error while fetching #{filtered_uri}" \ " (#{e})" end end diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index e9aa13a357..613bda4f84 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -128,7 +128,7 @@ module Bundler # evaluates a gemfile to remove the specified gem # from it. def remove_deps(gemfile_path) - initial_gemfile = IO.readlines(gemfile_path) + initial_gemfile = File.readlines(gemfile_path) Bundler.ui.info "Removing gems from #{gemfile_path}" @@ -181,7 +181,7 @@ module Bundler patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/ new_gemfile = [] multiline_removal = false - IO.readlines(gemfile_path).each do |line| + File.readlines(gemfile_path).each do |line| match_data = line.match(patterns) if match_data && is_not_within_comment?(line, match_data) multiline_removal = line.rstrip.end_with?(",") diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb index 02da06cee9..a718418fce 100644 --- a/lib/bundler/inline.rb +++ b/lib/bundler/inline.rb @@ -52,7 +52,7 @@ def gemfile(install = false, options = {}, &gemfile) builder.instance_eval(&gemfile) builder.check_primary_source_safety - Bundler.settings.temporary(:frozen => false) do + Bundler.settings.temporary(:deployment => false, :frozen => false) do definition = builder.to_definition(nil, true) def definition.lock(*); end definition.validate_runtime! diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1 index 667249c665..3a1cee9b81 100644 --- a/lib/bundler/man/bundle-config.1 +++ b/lib/bundler/man/bundle-config.1 @@ -199,7 +199,7 @@ The following is a list of all configuration keys and their purpose\. You can le \fBfrozen\fR (\fBBUNDLE_FROZEN\fR): Disallow changes to the \fBGemfile\fR\. When the \fBGemfile\fR is changed and the lockfile has not been updated, running Bundler commands will be blocked\. Defaults to \fBtrue\fR when \fB\-\-deployment\fR is used\. . .IP "\(bu" 4 -\fBgem\.github_username\fR (\fBBUNDLE_GEM__GITHUB_USERNAME\fR): Sets a GitHub username or organization to be used in \fBREADME\fR file when you create a new gem via \fBbundle gem\fR command\. It can be overriden by passing an explicit \fB\-\-github\-username\fR flag to \fBbundle gem\fR\. +\fBgem\.github_username\fR (\fBBUNDLE_GEM__GITHUB_USERNAME\fR): Sets a GitHub username or organization to be used in \fBREADME\fR file when you create a new gem via \fBbundle gem\fR command\. It can be overridden by passing an explicit \fB\-\-github\-username\fR flag to \fBbundle gem\fR\. . .IP "\(bu" 4 \fBgem\.push_key\fR (\fBBUNDLE_GEM__PUSH_KEY\fR): Sets the \fB\-\-key\fR parameter for \fBgem push\fR when using the \fBrake release\fR command with a private gemstash server\. @@ -470,6 +470,23 @@ export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x\-oauth\-basic . .IP "" 0 . +.P +Note that any configured credentials will be redacted by informative commands such as \fBbundle config list\fR or \fBbundle config get\fR, unless you use the \fB\-\-parseable\fR flag\. This is to avoid unintentially leaking credentials when copy\-pasting bundler output\. +. +.P +Also note that to guarantee a sane mapping between valid environment variable names and valid host names, bundler makes the following transformations: +. +.IP "\(bu" 4 +Any \fB\-\fR characters in a host name are mapped to a triple dash (\fB___\fR) in the corresponding enviroment variable\. +. +.IP "\(bu" 4 +Any \fB\.\fR characters in a host name are mapped to a double dash (\fB__\fR) in the corresponding environment variable\. +. +.IP "" 0 +. +.P +This means that if you have a gem server named \fBmy\.gem\-host\.com\fR, you\'ll need to use the \fBBUNDLE_MY__GEM___HOST__COM\fR variable to configure credentials for it through ENV\. +. .SH "CONFIGURE BUNDLER DIRECTORIES" Bundler\'s home, config, cache and plugin directories are able to be configured through environment variables\. The default location for Bundler\'s home directory is \fB~/\.bundle\fR, which all directories inherit from by default\. The following outlines the available environment variables and their default values . diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn index ba4bd5ff23..15bc5af778 100644 --- a/lib/bundler/man/bundle-config.1.ronn +++ b/lib/bundler/man/bundle-config.1.ronn @@ -196,7 +196,7 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html). Defaults to `true` when `--deployment` is used. * `gem.github_username` (`BUNDLE_GEM__GITHUB_USERNAME`): Sets a GitHub username or organization to be used in `README` file when you - create a new gem via `bundle gem` command. It can be overriden by passing an + create a new gem via `bundle gem` command. It can be overridden by passing an explicit `--github-username` flag to `bundle gem`. * `gem.push_key` (`BUNDLE_GEM__PUSH_KEY`): Sets the `--key` parameter for `gem push` when using the `rake release` @@ -376,6 +376,23 @@ where you can use personal OAuth tokens: export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x-oauth-basic +Note that any configured credentials will be redacted by informative commands +such as `bundle config list` or `bundle config get`, unless you use the +`--parseable` flag. This is to avoid unintentially leaking credentials when +copy-pasting bundler output. + +Also note that to guarantee a sane mapping between valid environment variable +names and valid host names, bundler makes the following transformations: + +* Any `-` characters in a host name are mapped to a triple dash (`___`) in the + corresponding enviroment variable. + +* Any `.` characters in a host name are mapped to a double dash (`__`) in the + corresponding environment variable. + +This means that if you have a gem server named `my.gem-host.com`, you'll need to +use the `BUNDLE_MY__GEM___HOST__COM` variable to configure credentials for it +through ENV. ## CONFIGURE BUNDLER DIRECTORIES diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index dddb468582..023c25b33e 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -164,7 +164,7 @@ module Bundler end # To be called from Cli class to pass the command and argument to - # approriate plugin class + # appropriate plugin class def exec_command(command, args) raise UndefinedCommandError, "Command `#{command}` not found" unless command? command @@ -183,7 +183,7 @@ module Bundler !index.source_plugin(name.to_s).nil? end - # @return [Class] that handles the source. The calss includes API::Source + # @return [Class] that handles the source. The class includes API::Source def source(name) raise UnknownSourceError, "Source #{name} not found" unless source? name diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index e95f15f7fb..2415ade200 100644 --- a/lib/bundler/retry.rb +++ b/lib/bundler/retry.rb @@ -49,7 +49,7 @@ module Bundler raise e end return true unless name - Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this + Bundler.ui.info "" unless Bundler.ui.debug? # Add new line in case dots preceded this Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug? end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 2c0edd0c68..612c56f041 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -13,6 +13,7 @@ module Bundler auto_install cache_all cache_all_platforms + clean default_install_uses_path deployment deployment_means_frozen @@ -26,11 +27,14 @@ module Bundler force_ruby_platform forget_cli_options frozen + gem.changelog gem.coc gem.mit + git.allow_insecure global_gem_cache ignore_messages init_gems_rb + inline no_install no_prune path_relative_to_cwd @@ -60,6 +64,22 @@ module Bundler without ].freeze + STRING_KEYS = %w[ + bin + cache_path + console + gem.ci + gem.github_username + gem.linter + gem.rubocop + gem.test + gemfile + path + shebang + system_bindir + trust-policy + ].freeze + DEFAULT_CONFIG = { "BUNDLE_SILENCE_DEPRECATIONS" => false, "BUNDLE_DISABLE_VERSION_CHECK" => true, @@ -125,8 +145,8 @@ module Bundler keys = @temporary.keys | @global_config.keys | @local_config.keys | @env_config.keys keys.map do |key| - key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase - end + key.sub(/^BUNDLE_/, "").gsub(/___/, "-").gsub(/__/, ".").downcase + end.sort end def local_overrides @@ -172,19 +192,19 @@ module Bundler locations = [] if value = @temporary[key] - locations << "Set for the current command: #{converted_value(value, exposed_key).inspect}" + locations << "Set for the current command: #{printable_value(value, exposed_key).inspect}" end if value = @local_config[key] - locations << "Set for your local app (#{local_config_file}): #{converted_value(value, exposed_key).inspect}" + locations << "Set for your local app (#{local_config_file}): #{printable_value(value, exposed_key).inspect}" end if value = @env_config[key] - locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}" + locations << "Set via #{key}: #{printable_value(value, exposed_key).inspect}" end if value = @global_config[key] - locations << "Set for the current user (#{global_config_file}): #{converted_value(value, exposed_key).inspect}" + locations << "Set for the current user (#{global_config_file}): #{printable_value(value, exposed_key).inspect}" end return ["You have not configured a value for `#{exposed_key}`"] if locations.empty? @@ -276,9 +296,7 @@ module Bundler end def key_for(key) - key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key - key = key.to_s.gsub(".", "__").upcase - "BUNDLE_#{key}" + self.class.key_for(key) end private @@ -313,6 +331,10 @@ module Bundler BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s)) end + def is_string(name) + STRING_KEYS.include?(name.to_s) || name.to_s.start_with?("local.") || name.to_s.start_with?("mirror.") || name.to_s.start_with?("build.") + end + def to_bool(value) case value when nil, /\A(false|f|no|n|0|)\z/i, false @@ -330,6 +352,14 @@ module Bundler ARRAY_KEYS.include?(key.to_s) end + def is_credential(key) + key == "gem.push_key" + end + + def is_userinfo(value) + value.include?(":") + end + def to_array(value) return [] unless value value.split(":").map(&:to_sym) @@ -376,6 +406,21 @@ module Bundler end end + def printable_value(value, key) + converted = converted_value(value, key) + return converted unless converted.is_a?(String) + + if is_string(key) + converted + elsif is_credential(key) + "[REDACTED]" + elsif is_userinfo(converted) + converted.gsub(/:.*$/, ":[REDACTED]") + else + converted + end + end + def global_config_file if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty? Pathname.new(ENV["BUNDLE_CONFIG"]) @@ -415,6 +460,12 @@ module Bundler \z /ix.freeze + def self.key_for(key) + key = normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key + key = key.to_s.gsub(".", "__").gsub("-", "___").upcase + "BUNDLE_#{key}" + end + # TODO: duplicates Rubygems#normalize_uri # TODO: is this the correct place to validate mirror URIs? def self.normalize_uri(uri) diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index cede580b0a..2b7cfd53b9 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -423,11 +423,11 @@ module Bundler def fetch_names(fetchers, dependency_names, index, override_dupes) fetchers.each do |f| if dependency_names - Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug? + Bundler.ui.info "Fetching gem metadata from #{URICredentialsFilter.credential_filtered_uri(f.uri)}", Bundler.ui.debug? index.use f.specs_with_retry(dependency_names, self), override_dupes Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over else - Bundler.ui.info "Fetching source index from #{f.uri}" + Bundler.ui.info "Fetching source index from #{URICredentialsFilter.credential_filtered_uri(f.uri)}" index.use f.specs_with_retry(nil, self), override_dupes end end diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index dfc3114c41..67669cdd0e 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -78,11 +78,17 @@ module Bundler def materialize(deps, missing_specs = nil) materialized = self.for(deps, [], false, true, !missing_specs).to_a - deps = materialized.map(&:name).uniq + + materialized.group_by(&:source).each do |source, specs| + next unless specs.any?{|s| s.is_a?(LazySpecification) } + + source.local! + names = -> { specs.map(&:name).uniq } + source.double_check_for(names) + end + materialized.map! do |s| next s unless s.is_a?(LazySpecification) - s.source.dependency_names = deps if s.source.respond_to?(:dependency_names=) - s.source.local! spec = s.__materialize__ unless spec unless missing_specs @@ -99,12 +105,17 @@ module Bundler # This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform) # @return [Array<Gem::Specification>] def materialized_for_all_platforms - names = @specs.map(&:name).uniq + @specs.group_by(&:source).each do |source, specs| + next unless specs.any?{|s| s.is_a?(LazySpecification) } + + source.local! + source.remote! + names = -> { specs.map(&:name).uniq } + source.double_check_for(names) + end + @specs.map do |s| next s unless s.is_a?(LazySpecification) - s.source.dependency_names = names if s.source.respond_to?(:dependency_names=) - s.source.local! - s.source.remote! spec = s.__materialize__ raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec spec diff --git a/lib/bundler/templates/Gemfile b/lib/bundler/templates/Gemfile index 1afd2cce67..d41f2719b4 100644 --- a/lib/bundler/templates/Gemfile +++ b/lib/bundler/templates/Gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } +git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } # gem "rails" diff --git a/lib/bundler/templates/gems.rb b/lib/bundler/templates/gems.rb index 547cd6e8d9..56a62a7a82 100644 --- a/lib/bundler/templates/gems.rb +++ b/lib/bundler/templates/gems.rb @@ -3,6 +3,6 @@ # A sample gems.rb source "https://rubygems.org" -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } +git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } # gem "rails" diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb b/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb index edf2366b7b..eeae79af3c 100644 --- a/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +++ b/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Bundler::Molinillo - # Provides information about specifcations and dependencies to the resolver, + # Provides information about specifications and dependencies to the resolver, # allowing the {Resolver} class to remain generic while still providing power # and flexibility. # diff --git a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb index 62c82b3dba..90a8d2e847 100644 --- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb @@ -252,7 +252,7 @@ class Bundler::Thor # flag<Regexp|String>:: the regexp or string to be replaced # replacement<String>:: the replacement, can be also given as a block # config<Hash>:: give :verbose => false to not log the status, and - # :force => true, to force the replacement regardles of runner behavior. + # :force => true, to force the replacement regardless of runner behavior. # # ==== Example # diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 1f5014bc1f..735cb09c88 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.2.16".freeze + VERSION = "2.2.17".freeze def self.bundler_major_version @bundler_major_version ||= VERSION.split(".").first.to_i diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 57574474ea..48d0117efb 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = "3.2.16".freeze + VERSION = "3.2.17".freeze end # Must be first since it unloads the prelude from 1.9.2 @@ -626,7 +626,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # Try requiring the gem version *or* stdlib version of psych. require 'psych' rescue ::LoadError - # If we can't load psych, thats fine, go on. + # If we can't load psych, that's fine, go on. else # If 'yaml' has already been required, then we have to # be sure to switch it over to the newly loaded psych. @@ -813,7 +813,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} ## # Safely write a file in binary mode on all platforms. def self.write_binary(path, data) - open(path, 'wb') do |io| + File.open(path, 'wb') do |io| begin io.flock(File::LOCK_EX) rescue *WRITE_BINARY_ERRORS @@ -824,7 +824,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} if Thread.main != Thread.current raise else - open(path, 'wb') do |io| + File.open(path, 'wb') do |io| io.write data end end diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 70825b88fd..dcab60c142 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -127,7 +127,7 @@ You can use `i` command instead of `install`. end def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags" + "#{program_name} [options] GEMNAME [GEMNAME ...] -- --build-flags" end def check_install_dir # :nodoc: diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb index 1e40758ec5..8012a9a0e1 100644 --- a/lib/rubygems/commands/open_command.rb +++ b/lib/rubygems/commands/open_command.rb @@ -36,7 +36,7 @@ class Gem::Commands::OpenCommand < Gem::Command end def usage # :nodoc: - "#{program_name} GEMNAME [-e COMMAND]" + "#{program_name} [-e COMMAND] GEMNAME" end def get_env_editor diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb index 7e8b66b300..a7930253d6 100644 --- a/lib/rubygems/commands/yank_command.rb +++ b/lib/rubygems/commands/yank_command.rb @@ -24,7 +24,7 @@ data you will need to change them immediately and yank your gem. end def usage # :nodoc: - "#{program_name} GEM -v VERSION [-p PLATFORM] [--key KEY_NAME] [--host HOST]" + "#{program_name} -v VERSION [-p PLATFORM] [--key KEY_NAME] [--host HOST] GEM" end def initialize diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 8aae67cd6b..e95bc06792 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -198,7 +198,7 @@ module Gem def self.default_bindir if defined? RUBY_FRAMEWORK_VERSION # mac framework support - '/usr/bin' + '/usr/local/bin' else # generic install RbConfig::CONFIG['bindir'] end diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 67285d4161..8c822cda95 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -60,12 +60,13 @@ module Gem::Deprecate target = klass ? "#{self}." : "#{self.class}#" msg = [ "NOTE: #{target}#{name} is deprecated", repl == :none ? " with no replacement" : "; use #{repl} instead", - ". It will be removed on or after %4d-%02d-01." % [year, month], + ". It will be removed on or after %4d-%02d." % [year, month], "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}", ] warn "#{msg.join}." unless Gem::Deprecate.skip send old, *args, &block end + ruby2_keywords name if respond_to?(:ruby2_keywords, true) end end @@ -90,6 +91,7 @@ module Gem::Deprecate warn "#{msg.join}." unless Gem::Deprecate.skip send old, *args, &block end + ruby2_keywords name if respond_to?(:ruby2_keywords, true) end end diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb index 31285ca962..e595459c87 100644 --- a/lib/rubygems/indexer.rb +++ b/lib/rubygems/indexer.rb @@ -136,7 +136,7 @@ class Gem::Indexer say "Generating #{name} index" Gem.time "Generated #{name} index" do - open(file, 'wb') do |io| + File.open(file, 'wb') do |io| specs = index.map do |*spec| # We have to splat here because latest_specs is an array, while the # others are hashes. diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb index 9448dc7bf3..1067bf7439 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Gem::Resolver::Molinillo - # Provides information about specifcations and dependencies to the resolver, + # Provides information about specifications and dependencies to the resolver, # allowing the {Resolver} class to remain generic while still providing power # and flexibility. # diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb index 1371ae9b14..08faef6578 100644 --- a/lib/rubygems/test_utilities.rb +++ b/lib/rubygems/test_utilities.rb @@ -76,7 +76,7 @@ class Gem::FakeFetcher def cache_update_path(uri, path = nil, update = true) if data = fetch_path(uri) - open(path, 'wb') {|io| io.write data } if path and update + File.open(path, 'wb') {|io| io.write data } if path and update data else Gem.read_binary(path) if path |