summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 12:49:40 +0300
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-09 12:44:10 +0900
commit8f37629519ad330032a38ac0e871b2912ed38a1b (patch)
treebb0529b77583d47993d8b0d608d68896aa3a5298
parent66508992483ae5d77b56a98427c50c772341c0ac (diff)
downloadruby-8f37629519ad330032a38ac0e871b2912ed38a1b.tar.gz
Merge bundler master from upstream.
Pick from 8dd59e3ba97eb80a599f8149f31bf40773b69dc0
-rw-r--r--lib/bundler.rb106
-rw-r--r--lib/bundler/bundler.gemspec22
-rw-r--r--lib/bundler/capistrano.rb4
-rw-r--r--lib/bundler/cli.rb61
-rw-r--r--lib/bundler/cli/add.rb43
-rw-r--r--lib/bundler/cli/common.rb11
-rw-r--r--lib/bundler/cli/doctor.rb2
-rw-r--r--lib/bundler/cli/exec.rb11
-rw-r--r--lib/bundler/cli/install.rb4
-rw-r--r--lib/bundler/cli/issue.rb2
-rw-r--r--lib/bundler/cli/outdated.rb8
-rw-r--r--lib/bundler/cli/package.rb2
-rw-r--r--lib/bundler/cli/plugin.rb2
-rw-r--r--lib/bundler/cli/update.rb42
-rw-r--r--lib/bundler/compact_index_client.rb4
-rw-r--r--lib/bundler/compact_index_client/updater.rb2
-rw-r--r--lib/bundler/compatibility_guard.rb2
-rw-r--r--lib/bundler/definition.rb20
-rw-r--r--lib/bundler/dependency.rb8
-rw-r--r--lib/bundler/deployment.rb2
-rw-r--r--lib/bundler/dsl.rb11
-rw-r--r--lib/bundler/env.rb9
-rw-r--r--lib/bundler/feature_flag.rb6
-rw-r--r--lib/bundler/fetcher.rb10
-rw-r--r--lib/bundler/fetcher/compact_index.rb6
-rw-r--r--lib/bundler/fetcher/dependency.rb2
-rw-r--r--lib/bundler/fetcher/downloader.rb1
-rw-r--r--lib/bundler/fetcher/index.rb3
-rw-r--r--lib/bundler/friendly_errors.rb4
-rw-r--r--lib/bundler/gem_helper.rb4
-rw-r--r--lib/bundler/gem_tasks.rb2
-rw-r--r--lib/bundler/gem_version_promoter.rb4
-rw-r--r--lib/bundler/injector.rb4
-rw-r--r--lib/bundler/inline.rb36
-rw-r--r--lib/bundler/installer.rb8
-rw-r--r--lib/bundler/installer/parallel_installer.rb4
-rw-r--r--lib/bundler/lazy_specification.rb2
-rw-r--r--lib/bundler/lockfile_parser.rb16
-rw-r--r--lib/bundler/match_platform.rb2
-rw-r--r--lib/bundler/plugin.rb17
-rw-r--r--lib/bundler/plugin/api.rb2
-rw-r--r--lib/bundler/plugin/index.rb4
-rw-r--r--lib/bundler/plugin/installer.rb4
-rw-r--r--lib/bundler/psyched_yaml.rb2
-rw-r--r--lib/bundler/resolver.rb6
-rw-r--r--lib/bundler/rubygems_ext.rb67
-rw-r--r--lib/bundler/rubygems_integration.rb472
-rw-r--r--lib/bundler/runtime.rb9
-rw-r--r--lib/bundler/settings.rb24
-rw-r--r--lib/bundler/setup.rb4
-rw-r--r--lib/bundler/shared_helpers.rb43
-rw-r--r--lib/bundler/source.rb10
-rw-r--r--lib/bundler/source/git.rb4
-rw-r--r--lib/bundler/source/metadata.rb3
-rw-r--r--lib/bundler/source/path.rb2
-rw-r--r--lib/bundler/source/rubygems.rb2
-rw-r--r--lib/bundler/stub_specification.rb4
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt4
-rw-r--r--lib/bundler/ui.rb6
-rw-r--r--lib/bundler/ui/rg_proxy.rb2
-rw-r--r--lib/bundler/ui/shell.rb8
-rw-r--r--lib/bundler/uri_credentials_filter.rb2
-rw-r--r--lib/bundler/vendor/fileutils/lib/fileutils.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo.rb12
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb4
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb12
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/errors.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb8
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/base.rb6
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell.rb6
-rw-r--r--lib/bundler/vendored_fileutils.rb2
-rw-r--r--lib/bundler/vendored_molinillo.rb2
-rw-r--r--lib/bundler/vendored_persistent.rb2
-rw-r--r--lib/bundler/vendored_thor.rb2
-rw-r--r--lib/bundler/version.rb18
-rw-r--r--lib/bundler/vlad.rb4
-rw-r--r--lib/bundler/yaml_serializer.rb2
-rw-r--r--man/bundle-add.112
-rw-r--r--man/bundle-add.1.txt16
-rw-r--r--man/bundle-add.ronn8
-rw-r--r--man/bundle-config.111
-rw-r--r--man/bundle-config.1.txt143
-rw-r--r--man/bundle-config.ronn5
-rw-r--r--man/bundle.14
-rw-r--r--man/bundle.1.txt4
-rw-r--r--man/bundle.ronn2
-rw-r--r--spec/bundler/bundler/bundler_spec.rb74
-rw-r--r--spec/bundler/bundler/cli_spec.rb14
-rw-r--r--spec/bundler/bundler/dsl_spec.rb78
-rw-r--r--spec/bundler/bundler/env_spec.rb49
-rw-r--r--spec/bundler/bundler/fetcher/compact_index_spec.rb7
-rw-r--r--spec/bundler/bundler/fetcher/downloader_spec.rb9
-rw-r--r--spec/bundler/bundler/fetcher/index_spec.rb23
-rw-r--r--spec/bundler/bundler/friendly_errors_spec.rb2
-rw-r--r--spec/bundler/bundler/plugin/events_spec.rb6
-rw-r--r--spec/bundler/bundler/ruby_version_spec.rb10
-rw-r--r--spec/bundler/bundler/shared_helpers_spec.rb2
-rw-r--r--spec/bundler/bundler/ui/shell_spec.rb24
-rw-r--r--spec/bundler/cache/git_spec.rb2
-rw-r--r--spec/bundler/commands/add_spec.rb26
-rw-r--r--spec/bundler/commands/binstubs_spec.rb18
-rw-r--r--spec/bundler/commands/check_spec.rb2
-rw-r--r--spec/bundler/commands/config_spec.rb38
-rw-r--r--spec/bundler/commands/exec_spec.rb35
-rw-r--r--spec/bundler/commands/init_spec.rb2
-rw-r--r--spec/bundler/commands/install_spec.rb4
-rw-r--r--spec/bundler/commands/licenses_spec.rb2
-rw-r--r--spec/bundler/commands/lock_spec.rb2
-rw-r--r--spec/bundler/commands/newgem_spec.rb40
-rw-r--r--spec/bundler/commands/outdated_spec.rb20
-rw-r--r--spec/bundler/commands/package_spec.rb2
-rw-r--r--spec/bundler/commands/post_bundle_message_spec.rb (renamed from spec/bundler/install/post_bundle_message_spec.rb)6
-rw-r--r--spec/bundler/commands/show_spec.rb37
-rw-r--r--spec/bundler/commands/update_spec.rb74
-rw-r--r--spec/bundler/install/bundler_spec.rb7
-rw-r--r--spec/bundler/install/deploy_spec.rb2
-rw-r--r--spec/bundler/install/failure_spec.rb8
-rw-r--r--spec/bundler/install/gemfile/gemspec_spec.rb4
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb18
-rw-r--r--spec/bundler/install/gemfile/path_spec.rb64
-rw-r--r--spec/bundler/install/gemfile/sources_spec.rb51
-rw-r--r--spec/bundler/install/gems/compact_index_spec.rb2
-rw-r--r--spec/bundler/install/gems/flex_spec.rb4
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb6
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb16
-rw-r--r--spec/bundler/install/gems/sudo_spec.rb27
-rw-r--r--spec/bundler/install/gemspecs_spec.rb4
-rw-r--r--spec/bundler/install/path_spec.rb75
-rw-r--r--spec/bundler/lock/lockfile_spec.rb185
-rw-r--r--spec/bundler/other/cli_dispatch_spec.rb8
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb58
-rw-r--r--spec/bundler/quality_spec.rb23
-rw-r--r--spec/bundler/realworld/edgecases_spec.rb4
-rw-r--r--spec/bundler/realworld/gemfile_source_header_spec.rb2
-rw-r--r--spec/bundler/realworld/mirror_probe_spec.rb4
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb6
-rw-r--r--spec/bundler/runtime/inline_spec.rb43
-rw-r--r--spec/bundler/runtime/require_spec.rb10
-rw-r--r--spec/bundler/runtime/setup_spec.rb50
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb35
-rw-r--r--spec/bundler/spec_helper.rb30
-rw-r--r--spec/bundler/support/code_climate.rb26
-rw-r--r--spec/bundler/support/command_execution.rb8
-rw-r--r--spec/bundler/support/hax.rb2
-rw-r--r--spec/bundler/support/helpers.rb4
-rw-r--r--spec/bundler/support/matchers.rb8
-rw-r--r--spec/bundler/support/platforms.rb2
-rw-r--r--spec/bundler/update/git_spec.rb4
155 files changed, 1312 insertions, 1594 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index f792a3bc98..d8f9462c6d 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-require "bundler/compatibility_guard"
+require_relative "bundler/compatibility_guard"
-require "bundler/vendored_fileutils"
+require_relative "bundler/vendored_fileutils"
require "pathname"
require "rbconfig"
-require "bundler/errors"
-require "bundler/environment_preserver"
-require "bundler/plugin"
-require "bundler/rubygems_ext"
-require "bundler/rubygems_integration"
-require "bundler/version"
-require "bundler/constants"
-require "bundler/current_ruby"
-require "bundler/build_metadata"
+require_relative "bundler/errors"
+require_relative "bundler/environment_preserver"
+require_relative "bundler/plugin"
+require_relative "bundler/rubygems_ext"
+require_relative "bundler/rubygems_integration"
+require_relative "bundler/version"
+require_relative "bundler/constants"
+require_relative "bundler/current_ruby"
+require_relative "bundler/build_metadata"
module Bundler
environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS)
@@ -22,43 +22,43 @@ module Bundler
ENV.replace(environment_preserver.backup)
SUDO_MUTEX = Mutex.new
- autoload :Definition, "bundler/definition"
- autoload :Dependency, "bundler/dependency"
- autoload :DepProxy, "bundler/dep_proxy"
- autoload :Deprecate, "bundler/deprecate"
- autoload :Dsl, "bundler/dsl"
- autoload :EndpointSpecification, "bundler/endpoint_specification"
- autoload :Env, "bundler/env"
- autoload :Fetcher, "bundler/fetcher"
- autoload :FeatureFlag, "bundler/feature_flag"
- autoload :GemHelper, "bundler/gem_helper"
- autoload :GemHelpers, "bundler/gem_helpers"
- autoload :GemRemoteFetcher, "bundler/gem_remote_fetcher"
- autoload :GemVersionPromoter, "bundler/gem_version_promoter"
- autoload :Graph, "bundler/graph"
- autoload :Index, "bundler/index"
- autoload :Injector, "bundler/injector"
- autoload :Installer, "bundler/installer"
- autoload :LazySpecification, "bundler/lazy_specification"
- autoload :LockfileParser, "bundler/lockfile_parser"
- autoload :MatchPlatform, "bundler/match_platform"
- autoload :ProcessLock, "bundler/process_lock"
- autoload :RemoteSpecification, "bundler/remote_specification"
- autoload :Resolver, "bundler/resolver"
- autoload :Retry, "bundler/retry"
- autoload :RubyDsl, "bundler/ruby_dsl"
- autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
- autoload :RubyVersion, "bundler/ruby_version"
- autoload :Runtime, "bundler/runtime"
- autoload :Settings, "bundler/settings"
- autoload :SharedHelpers, "bundler/shared_helpers"
- autoload :Source, "bundler/source"
- autoload :SourceList, "bundler/source_list"
- autoload :SpecSet, "bundler/spec_set"
- autoload :StubSpecification, "bundler/stub_specification"
- autoload :UI, "bundler/ui"
- autoload :URICredentialsFilter, "bundler/uri_credentials_filter"
- autoload :VersionRanges, "bundler/version_ranges"
+ autoload :Definition, File.expand_path("bundler/definition", __dir__)
+ autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
+ autoload :DepProxy, File.expand_path("bundler/dep_proxy", __dir__)
+ autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
+ autoload :Dsl, File.expand_path("bundler/dsl", __dir__)
+ autoload :EndpointSpecification, File.expand_path("bundler/endpoint_specification", __dir__)
+ autoload :Env, File.expand_path("bundler/env", __dir__)
+ autoload :Fetcher, File.expand_path("bundler/fetcher", __dir__)
+ autoload :FeatureFlag, File.expand_path("bundler/feature_flag", __dir__)
+ autoload :GemHelper, File.expand_path("bundler/gem_helper", __dir__)
+ autoload :GemHelpers, File.expand_path("bundler/gem_helpers", __dir__)
+ autoload :GemRemoteFetcher, File.expand_path("bundler/gem_remote_fetcher", __dir__)
+ autoload :GemVersionPromoter, File.expand_path("bundler/gem_version_promoter", __dir__)
+ autoload :Graph, File.expand_path("bundler/graph", __dir__)
+ autoload :Index, File.expand_path("bundler/index", __dir__)
+ autoload :Injector, File.expand_path("bundler/injector", __dir__)
+ autoload :Installer, File.expand_path("bundler/installer", __dir__)
+ autoload :LazySpecification, File.expand_path("bundler/lazy_specification", __dir__)
+ autoload :LockfileParser, File.expand_path("bundler/lockfile_parser", __dir__)
+ autoload :MatchPlatform, File.expand_path("bundler/match_platform", __dir__)
+ autoload :ProcessLock, File.expand_path("bundler/process_lock", __dir__)
+ autoload :RemoteSpecification, File.expand_path("bundler/remote_specification", __dir__)
+ autoload :Resolver, File.expand_path("bundler/resolver", __dir__)
+ autoload :Retry, File.expand_path("bundler/retry", __dir__)
+ autoload :RubyDsl, File.expand_path("bundler/ruby_dsl", __dir__)
+ autoload :RubyGemsGemInstaller, File.expand_path("bundler/rubygems_gem_installer", __dir__)
+ autoload :RubyVersion, File.expand_path("bundler/ruby_version", __dir__)
+ autoload :Runtime, File.expand_path("bundler/runtime", __dir__)
+ autoload :Settings, File.expand_path("bundler/settings", __dir__)
+ autoload :SharedHelpers, File.expand_path("bundler/shared_helpers", __dir__)
+ autoload :Source, File.expand_path("bundler/source", __dir__)
+ autoload :SourceList, File.expand_path("bundler/source_list", __dir__)
+ autoload :SpecSet, File.expand_path("bundler/spec_set", __dir__)
+ autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
+ autoload :UI, File.expand_path("bundler/ui", __dir__)
+ autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
+ autoload :VersionRanges, File.expand_path("bundler/version_ranges", __dir__)
class << self
def configure
@@ -197,19 +197,19 @@ module Bundler
def user_bundle_path(dir = "home")
env_var, fallback = case dir
when "home"
- ["BUNDLE_USER_HOME", Pathname.new(user_home).join(".bundle")]
+ ["BUNDLE_USER_HOME", proc { Pathname.new(user_home).join(".bundle") }]
when "cache"
- ["BUNDLE_USER_CACHE", user_bundle_path.join("cache")]
+ ["BUNDLE_USER_CACHE", proc { user_bundle_path.join("cache") }]
when "config"
- ["BUNDLE_USER_CONFIG", user_bundle_path.join("config")]
+ ["BUNDLE_USER_CONFIG", proc { user_bundle_path.join("config") }]
when "plugin"
- ["BUNDLE_USER_PLUGIN", user_bundle_path.join("plugin")]
+ ["BUNDLE_USER_PLUGIN", proc { user_bundle_path.join("plugin") }]
else
raise BundlerError, "Unknown user path requested: #{dir}"
end
# `fallback` will already be a Pathname, but Pathname.new() is
# idempotent so it's OK
- Pathname.new(ENV.fetch(env_var, fallback))
+ Pathname.new(ENV.fetch(env_var, &fallback))
end
def user_cache
diff --git a/lib/bundler/bundler.gemspec b/lib/bundler/bundler.gemspec
index d8abb2b16f..6ce881e51a 100644
--- a/lib/bundler/bundler.gemspec
+++ b/lib/bundler/bundler.gemspec
@@ -1,10 +1,10 @@
# frozen_string_literal: true
begin
- require File.expand_path("../lib/bundler/version", __FILE__)
+ require_relative "lib/bundler/version"
rescue LoadError
# for Ruby core repository
- require File.expand_path("../version", __FILE__)
+ require_relative "version"
end
Gem::Specification.new do |s|
@@ -31,27 +31,23 @@ Gem::Specification.new do |s|
}
end
- if s.version >= Gem::Version.new("2.a".dup)
- s.required_ruby_version = ">= 2.3.0"
- s.required_rubygems_version = ">= 2.5.0"
- else
- s.required_ruby_version = ">= 1.8.7"
- s.required_rubygems_version = ">= 1.3.6"
- end
+ s.required_ruby_version = ">= 2.3.0"
+ s.required_rubygems_version = ">= 2.5.0"
s.add_development_dependency "automatiek", "~> 0.1.0"
s.add_development_dependency "rake", "~> 12.0"
s.add_development_dependency "ronn", "~> 0.7.3"
s.add_development_dependency "rspec", "~> 3.6"
- s.add_development_dependency "rubocop", "= 0.65.0"
+ s.add_development_dependency "rubocop", "= 0.68.1"
+ s.add_development_dependency "rubocop-performance", "~> 1.1"
- # s.files = Dir.glob("{lib,exe}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
+ s.files = Dir.glob("{lib,exe}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
# we don't check in man pages, but we need to ship them because
# we use them to generate the long-form help for each command.
- # s.files += Dir.glob("man/**/*")
+ s.files += Dir.glob("man/**/*")
# Include the CHANGELOG.md, LICENSE.md, README.md manually
- # s.files += %w[CHANGELOG.md LICENSE.md README.md]
+ s.files += %w[CHANGELOG.md LICENSE.md README.md]
# include the gemspec itself because warbler breaks w/o it
s.files += %w[bundler.gemspec]
diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb
index 1b7145b72b..573df95043 100644
--- a/lib/bundler/capistrano.rb
+++ b/lib/bundler/capistrano.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/shared_helpers"
+require_relative "shared_helpers"
Bundler::SharedHelpers.major_deprecation 2,
"The Bundler task for Capistrano. Please use http://github.com/capistrano/bundler"
@@ -8,7 +8,7 @@ Bundler::SharedHelpers.major_deprecation 2,
#
# Add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
# Bundler will be activated after each new deployment.
-require "bundler/deployment"
+require_relative "deployment"
require "capistrano/version"
if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 4e3735847e..dd733a22ed 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -1,11 +1,10 @@
# frozen_string_literal: true
-require "bundler"
-require "bundler/vendored_thor"
+require_relative "vendored_thor"
module Bundler
class CLI < Thor
- require "bundler/cli/common"
+ require_relative "cli/common"
package_name "Bundler"
@@ -139,7 +138,7 @@ module Bundler
D
method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
def init
- require "bundler/cli/init"
+ require_relative "cli/init"
Init.new(options.dup).run
end
@@ -157,7 +156,7 @@ module Bundler
"Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
map "c" => "check"
def check
- require "bundler/cli/check"
+ require_relative "cli/check"
Check.new(options).run
end
@@ -168,7 +167,7 @@ module Bundler
method_option "install", :type => :boolean, :banner =>
"Runs 'bundle install' after removing the gems from the Gemfile"
def remove(*gems)
- require "bundler/cli/remove"
+ require_relative "cli/remove"
Remove.new(gems, options).run
end
@@ -230,7 +229,7 @@ module Bundler
remembered_flag_deprecation(option)
end
- require "bundler/cli/install"
+ require_relative "cli/install"
Bundler.settings.temporary(:no_install => false) do
Install.new(options.dup).run
end
@@ -276,7 +275,7 @@ module Bundler
"Update everything."
def update(*gems)
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
- require "bundler/cli/update"
+ require_relative "cli/update"
Bundler.settings.temporary(:no_install => false) do
Update.new(options, gems).run
end
@@ -312,7 +311,7 @@ module Bundler
Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
end
end
- require "bundler/cli/show"
+ require_relative "cli/show"
Show.new(options, gem_name).run
end
end
@@ -323,7 +322,7 @@ module Bundler
method_option "without-group", :type => :string, :banner => "print all gems except from a group"
method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
def list
- require "bundler/cli/list"
+ require_relative "cli/list"
List.new(options).run
end
@@ -332,7 +331,7 @@ module Bundler
desc "info GEM [OPTIONS]", "Show information for the given gem"
method_option "path", :type => :boolean, :banner => "Print full path to gem"
def info(gem_name)
- require "bundler/cli/info"
+ require_relative "cli/info"
Info.new(options, gem_name).run
end
@@ -353,7 +352,7 @@ module Bundler
method_option "all", :type => :boolean, :banner =>
"Install binstubs for all gems"
def binstubs(*gems)
- require "bundler/cli/binstubs"
+ require_relative "cli/binstubs"
Binstubs.new(options, gems).run
end
@@ -364,12 +363,14 @@ module Bundler
method_option "version", :aliases => "-v", :type => :string
method_option "group", :aliases => "-g", :type => :string
method_option "source", :aliases => "-s", :type => :string
+ method_option "git", :type => :string
+ method_option "branch", :type => :string
method_option "skip-install", :type => :boolean, :banner =>
"Adds gem to the Gemfile but does not install it"
method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
def add(*gems)
- require "bundler/cli/add"
+ require_relative "cli/add"
Add.new(options.dup, gems).run
end
@@ -405,7 +406,7 @@ module Bundler
method_option "only-explicit", :type => :boolean, :banner =>
"Only list gems specified in your Gemfile, not their dependencies"
def outdated(*gems)
- require "bundler/cli/outdated"
+ require_relative "cli/outdated"
Outdated.new(options, gems).run
end
@@ -420,7 +421,7 @@ module Bundler
method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
def cache
- require "bundler/cli/cache"
+ require_relative "cli/cache"
Cache.new(options).run
end
end
@@ -448,7 +449,7 @@ module Bundler
bundle without having to download any additional gems.
D
def package
- require "bundler/cli/package"
+ require_relative "cli/package"
Package.new(options).run
end
map %w[pack] => :package
@@ -463,7 +464,7 @@ module Bundler
D
map "e" => "exec"
def exec(*args)
- require "bundler/cli/exec"
+ require_relative "cli/exec"
Exec.new(options, args).run
end
@@ -479,19 +480,19 @@ module Bundler
will show the current value, as well as any superceded values and
where they were specified.
D
- require "bundler/cli/config"
+ require_relative "cli/config"
subcommand "config", Config
desc "open GEM", "Opens the source directory of the given bundled gem"
def open(name)
- require "bundler/cli/open"
+ require_relative "cli/open"
Open.new(options, name).run
end
unless Bundler.feature_flag.bundler_3_mode?
desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
def console(group = nil)
- require "bundler/cli/console"
+ require_relative "cli/console"
Console.new(options, group).run
end
end
@@ -539,7 +540,7 @@ module Bundler
method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
def viz
SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
- require "bundler/cli/viz"
+ require_relative "cli/viz"
Viz.new(options.dup).run
end
end
@@ -563,7 +564,7 @@ module Bundler
def gem_command.run(instance, args = [])
arity = 1 # name
- require "bundler/cli/gem"
+ require_relative "cli/gem"
cmd_args = args + [instance]
cmd_args.unshift(instance.options)
@@ -591,7 +592,7 @@ module Bundler
method_option "force", :type => :boolean, :default => false, :banner =>
"Forces clean even if --path is not set"
def clean
- require "bundler/cli/clean"
+ require_relative "cli/clean"
Clean.new(options.dup).run
end
@@ -599,7 +600,7 @@ module Bundler
method_option "ruby", :type => :boolean, :default => false, :banner =>
"only display ruby related platform information"
def platform
- require "bundler/cli/platform"
+ require_relative "cli/platform"
Platform.new(options).run
end
@@ -610,7 +611,7 @@ module Bundler
"Install gem into a bundler group"
def inject(name, version)
SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
- require "bundler/cli/inject"
+ require_relative "cli/inject"
Inject.new(options.dup, name, version).run
end
@@ -642,7 +643,7 @@ module Bundler
method_option "conservative", :type => :boolean, :banner =>
"If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
def lock
- require "bundler/cli/lock"
+ require_relative "cli/lock"
Lock.new(options).run
end
@@ -662,13 +663,13 @@ module Bundler
method_option "quiet", :type => :boolean, :banner =>
"Only output warnings and errors."
def doctor
- require "bundler/cli/doctor"
+ require_relative "cli/doctor"
Doctor.new(options).run
end
desc "issue", "Learn how to report an issue in Bundler"
def issue
- require "bundler/cli/issue"
+ require_relative "cli/issue"
Issue.new.run
end
@@ -679,12 +680,12 @@ module Bundler
checkout --force`.
D
def pristine(*gems)
- require "bundler/cli/pristine"
+ require_relative "cli/pristine"
Pristine.new(gems).run
end
if Bundler.feature_flag.plugins?
- require "bundler/cli/plugin"
+ require_relative "cli/plugin"
desc "plugin", "Manage the bundler plugins"
subcommand "plugin", Plugin
end
diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb
index 9709e71be0..7c6235f17c 100644
--- a/lib/bundler/cli/add.rb
+++ b/lib/bundler/cli/add.rb
@@ -2,34 +2,45 @@
module Bundler
class CLI::Add
+ attr_reader :gems, :options, :version
+
def initialize(options, gems)
@gems = gems
@options = options
- @options[:group] = @options[:group].split(",").map(&:strip) if !@options[:group].nil? && !@options[:group].empty?
+ @options[:group] = options[:group].split(",").map(&:strip) unless options[:group].nil?
+ @version = options[:version].split(",").map(&:strip) unless options[:version].nil?
end
def run
- raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if @options[:strict] && @options[:optimistic]
-
- # raise error when no gems are specified
- raise InvalidOption, "Please specify gems to add." if @gems.empty?
+ validate_options!
+ inject_dependencies
+ perform_bundle_install unless options["skip-install"]
+ end
- version = @options[:version].nil? ? nil : @options[:version].split(",").map(&:strip)
+ private
- unless version.nil?
- version.each do |v|
- raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
- end
- end
+ def perform_bundle_install
+ Installer.install(Bundler.root, Bundler.definition)
+ end
- dependencies = @gems.map {|g| Bundler::Dependency.new(g, version, @options) }
+ def inject_dependencies
+ dependencies = gems.map {|g| Bundler::Dependency.new(g, version, options) }
Injector.inject(dependencies,
- :conservative_versioning => @options[:version].nil?, # Perform conservative versioning only when version is not specified
- :optimistic => @options[:optimistic],
- :strict => @options[:strict])
+ :conservative_versioning => options[:version].nil?, # Perform conservative versioning only when version is not specified
+ :optimistic => options[:optimistic],
+ :strict => options[:strict])
+ end
+
+ def validate_options!
+ raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic]
- Installer.install(Bundler.root, Bundler.definition) unless @options["skip-install"]
+ # raise error when no gems are specified
+ raise InvalidOption, "Please specify gems to add." if gems.empty?
+
+ version.to_a.each do |v|
+ raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
+ end
end
end
end
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
index 9ea52baa6b..cec7bcadb4 100644
--- a/lib/bundler/cli/common.rb
+++ b/lib/bundler/cli/common.rb
@@ -14,17 +14,18 @@ module Bundler
Bundler.ui.info msg
end
- def self.output_without_groups_message
+ def self.output_without_groups_message(command)
return if Bundler.settings[:without].empty?
- Bundler.ui.confirm without_groups_message
+ Bundler.ui.confirm without_groups_message(command)
end
- def self.without_groups_message
+ def self.without_groups_message(command)
+ command_in_past_tense = command == :install ? "installed" : "updated"
groups = Bundler.settings[:without]
group_list = [groups[0...-1].join(", "), groups[-1..-1]].
reject {|s| s.to_s.empty? }.join(" and ")
group_str = groups.size == 1 ? "group" : "groups"
- "Gems in the #{group_str} #{group_list} were not installed."
+ "Gems in the #{group_str} #{group_list} were not #{command_in_past_tense}."
end
def self.select_spec(name, regex_match = nil)
@@ -59,7 +60,7 @@ module Bundler
end
def self.gem_not_found_message(missing_gem_name, alternatives)
- require "bundler/similarity_detector"
+ require_relative "../similarity_detector"
message = "Could not find gem '#{missing_gem_name}'."
alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a }
suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)
diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb
index 6d038937c0..1b3913a300 100644
--- a/lib/bundler/cli/doctor.rb
+++ b/lib/bundler/cli/doctor.rb
@@ -56,7 +56,7 @@ module Bundler
end
def check!
- require "bundler/cli/check"
+ require_relative "check"
Bundler::CLI::Check.new({}).run
end
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb
index c29d632307..5dcf4a01ef 100644
--- a/lib/bundler/cli/exec.rb
+++ b/lib/bundler/cli/exec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/current_ruby"
+require_relative "../current_ruby"
module Bundler
class CLI::Exec
@@ -27,12 +27,7 @@ module Bundler
if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path)
return kernel_load(bin_path, *args)
end
- # First, try to exec directly to something in PATH
- if Bundler.current_ruby.jruby_18?
- kernel_exec(bin_path, *args)
- else
- kernel_exec([bin_path, cmd], *args)
- end
+ kernel_exec(bin_path, *args)
else
# exec using the given command
kernel_exec(cmd, *args)
@@ -69,7 +64,7 @@ module Bundler
Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle)
ui = Bundler.ui
Bundler.ui = nil
- require "bundler/setup"
+ require_relative "../setup"
TRAPPED_SIGNALS.each {|s| trap(s, "DEFAULT") }
Kernel.load(file)
rescue SystemExit, SignalException
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 03edc7fbd2..d823fb632f 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -66,7 +66,7 @@ module Bundler
Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
- Bundler::CLI::Common.output_without_groups_message
+ Bundler::CLI::Common.output_without_groups_message(:install)
if Bundler.use_system_gems?
Bundler.ui.confirm "Use `bundle info [gemname]` to see where a bundled gem is installed."
@@ -80,7 +80,7 @@ module Bundler
warn_ambiguous_gems
if CLI::Common.clean_after_install?
- require "bundler/cli/clean"
+ require_relative "clean"
Bundler::CLI::Clean.new(options).run
end
rescue GemNotFound, VersionConflict => e
diff --git a/lib/bundler/cli/issue.rb b/lib/bundler/cli/issue.rb
index bba1619340..054ce76315 100644
--- a/lib/bundler/cli/issue.rb
+++ b/lib/bundler/cli/issue.rb
@@ -33,7 +33,7 @@ module Bundler
end
def doctor
- require "bundler/cli/doctor"
+ require_relative "doctor"
Bundler::CLI::Doctor.new({}).run
end
end
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 3a0521de1e..857caf0a03 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -133,7 +133,7 @@ module Bundler
unless options[:parseable]
if groups
- Bundler.ui.info "===== Group #{groups} ====="
+ Bundler.ui.info "===== #{groups_text("Group", groups)} ====="
else
Bundler.ui.info "===== Without group ====="
end
@@ -167,6 +167,10 @@ module Bundler
private
+ def groups_text(group_text, groups)
+ "#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\""
+ end
+
def retrieve_active_spec(strict, definition, current_spec)
if strict
active_spec = definition.find_resolved_spec(current_spec)
@@ -212,7 +216,7 @@ module Bundler
elsif options_include_groups || !groups
" * #{spec_outdated_info}"
else
- " * #{spec_outdated_info} in groups \"#{groups}\""
+ " * #{spec_outdated_info} in #{groups_text("group", groups)}"
end
Bundler.ui.info output_message.rstrip
diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb
index cd01ce422e..120a3fdcf3 100644
--- a/lib/bundler/cli/package.rb
+++ b/lib/bundler/cli/package.rb
@@ -25,7 +25,7 @@ module Bundler
private
def install
- require "bundler/cli/install"
+ require_relative "install"
options = self.options.dup
if Bundler.settings[:cache_all_platforms]
options["local"] = false
diff --git a/lib/bundler/cli/plugin.rb b/lib/bundler/cli/plugin.rb
index b5dd5b6d4b..1155c4ec9b 100644
--- a/lib/bundler/cli/plugin.rb
+++ b/lib/bundler/cli/plugin.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/vendored_thor"
+require_relative "../vendored_thor"
module Bundler
class CLI::Plugin < Thor
desc "install PLUGINS", "Install the plugin from the source"
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index b088853768..afd386bd54 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -58,24 +58,44 @@ module Bundler
Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
Bundler.definition.validate_runtime!
+
+ if locked_gems = Bundler.definition.locked_gems
+ previous_locked_info = locked_gems.specs.reduce({}) do |h, s|
+ h[s.name] = { :spec => s, :version => s.version, :source => s.source.to_s }
+ h
+ end
+ end
+
installer = Installer.install Bundler.root, Bundler.definition, opts
Bundler.load.cache if Bundler.app_cache.exist?
if CLI::Common.clean_after_install?
- require "bundler/cli/clean"
+ require_relative "clean"
Bundler::CLI::Clean.new(options).run
end
- if locked_gems = Bundler.definition.locked_gems
+ if locked_gems
gems.each do |name|
- locked_version = locked_gems.specs.find {|s| s.name == name }
- locked_version &&= locked_version.version
- next unless locked_version
- new_version = Bundler.definition.specs[name].first
- new_version &&= new_version.version
- if !new_version
- Bundler.ui.warn "Bundler attempted to update #{name} but it was removed from the bundle"
- elsif new_version < locked_version
+ locked_info = previous_locked_info[name]
+ next unless locked_info
+
+ locked_spec = locked_info[:spec]
+ new_spec = Bundler.definition.specs[name].first
+ unless new_spec
+ if Bundler.rubygems.platforms.none? {|p| locked_spec.match_platform(p) }
+ Bundler.ui.warn "Bundler attempted to update #{name} but it was not considered because it is for a different platform from the current one"
+ end
+
+ next
+ end
+
+ locked_source = locked_info[:source]
+ new_source = new_spec.source.to_s
+ next if locked_source != new_source
+
+ new_version = new_spec.version
+ locked_version = locked_info[:version]
+ if new_version < locked_version
Bundler.ui.warn "Note: #{name} version regressed from #{locked_version} to #{new_version}"
elsif new_version == locked_version
Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same"
@@ -84,7 +104,7 @@ module Bundler
end
Bundler.ui.confirm "Bundle updated!"
- Bundler::CLI::Common.output_without_groups_message
+ Bundler::CLI::Common.output_without_groups_message(:update)
Bundler::CLI::Common.output_post_install_messages installer.post_install_messages
end
end
diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb
index 2f713041c8..a5120dbba4 100644
--- a/lib/bundler/compact_index_client.rb
+++ b/lib/bundler/compact_index_client.rb
@@ -13,8 +13,8 @@ module Bundler
class Error < StandardError; end
- require "bundler/compact_index_client/cache"
- require "bundler/compact_index_client/updater"
+ require_relative "compact_index_client/cache"
+ require_relative "compact_index_client/updater"
attr_reader :directory
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb
index d77285072c..40232019bc 100644
--- a/lib/bundler/compact_index_client/updater.rb
+++ b/lib/bundler/compact_index_client/updater.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/vendored_fileutils"
+require_relative "../vendored_fileutils"
require "stringio"
require "zlib"
diff --git a/lib/bundler/compatibility_guard.rb b/lib/bundler/compatibility_guard.rb
index 958116ce55..eaff1a10d4 100644
--- a/lib/bundler/compatibility_guard.rb
+++ b/lib/bundler/compatibility_guard.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: false
-require "bundler/version"
+require_relative "version"
if Bundler::VERSION.split(".").first.to_i >= 2
if Gem::Version.new(Object::RUBY_VERSION.dup) < Gem::Version.new("2.3")
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index f9daae067c..76950ff96a 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/lockfile_parser"
+require_relative "lockfile_parser"
require "set"
module Bundler
@@ -385,7 +385,7 @@ module Bundler
end
def to_lock
- require "bundler/lockfile_generator"
+ require_relative "lockfile_generator"
LockfileGenerator.generate(self)
end
@@ -782,7 +782,7 @@ module Bundler
# Path sources have special logic
if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
- other_sources_specs = begin
+ new_specs = begin
s.source.specs
rescue PathError, GitError
# if we won't need the source (according to the lockfile),
@@ -794,16 +794,18 @@ module Bundler
raise
end
- other = other_sources_specs[s].first
+ new_spec = new_specs[s].first
# If the spec is no longer in the path source, unlock it. This
# commonly happens if the version changed in the gemspec
- next unless other
+ next unless new_spec
- deps2 = other.dependencies.select {|d| d.type != :development }
- runtime_dependencies = s.dependencies.select {|d| d.type != :development }
- # If the dependencies of the path source have changed, unlock it
- next unless runtime_dependencies.sort == deps2.sort
+ new_runtime_deps = new_spec.dependencies.select {|d| d.type != :development }
+ old_runtime_deps = s.dependencies.select {|d| d.type != :development }
+ # If the dependencies of the path source have changed and locked spec can't satisfy new dependencies, unlock it
+ next unless new_runtime_deps.sort == old_runtime_deps.sort || new_runtime_deps.all? {|d| satisfies_locked_spec?(d) }
+
+ s.dependencies.replace(new_spec.dependencies)
end
converged << s
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 8840ad6a9c..0d588bc892 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
require "rubygems/dependency"
-require "bundler/shared_helpers"
-require "bundler/rubygems_ext"
+require_relative "shared_helpers"
+require_relative "rubygems_ext"
module Bundler
class Dependency < Gem::Dependency
attr_reader :autorequire
- attr_reader :groups, :platforms, :gemfile
+ attr_reader :groups, :platforms, :gemfile, :git, :branch
PLATFORM_MAP = {
:ruby => Gem::Platform::RUBY,
@@ -84,6 +84,8 @@ module Bundler
@autorequire = nil
@groups = Array(options["group"] || :default).map(&:to_sym)
@source = options["source"]
+ @git = options["git"]
+ @branch = options["branch"]
@platforms = Array(options["platforms"])
@env = options["env"]
@should_include = options.fetch("should_include", true)
diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb
index 291e158ca0..b432ae6ae1 100644
--- a/lib/bundler/deployment.rb
+++ b/lib/bundler/deployment.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/shared_helpers"
+require_relative "shared_helpers"
Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \
"Capistrano, but Capistrano provides its own integration with " \
"Bundler via the capistrano-bundler gem. Use it instead."
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 7424a5c8a4..534c9b5537 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require "bundler/dependency"
-require "bundler/ruby_dsl"
+require_relative "dependency"
+require_relative "ruby_dsl"
module Bundler
class Dsl
@@ -291,12 +291,7 @@ module Bundler
"https://github.com/#{repo_name}.git"
RUBY
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
- if Bundler.feature_flag.github_https?
- "https://github.com/#{repo_name}.git"
- else
- Bundler::SharedHelpers.major_deprecation 2, "Setting `github.https` to false is deprecated and won't be supported in the future."
- "git://github.com/#{repo_name}.git"
- end
+ "https://github.com/#{repo_name}.git"
end
git_source(:gist) do |repo_name|
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index 9cd9b8baca..a08db08aa0 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require "bundler/rubygems_integration"
-require "bundler/source/git/git_proxy"
+require_relative "rubygems_integration"
+require_relative "source/git/git_proxy"
module Bundler
class Env
@@ -100,8 +100,9 @@ module Bundler
out << [" Full Path", Gem.ruby]
out << [" Config Dir", Pathname.new(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE).dirname]
out << ["RubyGems", Gem::VERSION]
- out << [" Gem Home", ENV.fetch("GEM_HOME") { Gem.dir }]
- out << [" Gem Path", ENV.fetch("GEM_PATH") { Gem.path.join(File::PATH_SEPARATOR) }]
+ out << [" Gem Home", Gem.dir]
+ out << [" Gem Path", Gem.path.join(File::PATH_SEPARATOR)]
+ out << [" User Home", Gem.user_home]
out << [" User Path", Gem.user_dir]
out << [" Bin Dir", Gem.bindir]
if defined?(OpenSSL)
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index 982f0fa540..a45694dd8e 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -36,16 +36,14 @@ module Bundler
settings_flag(:default_install_uses_path) { bundler_3_mode? }
settings_flag(:deployment_means_frozen) { bundler_3_mode? }
settings_flag(:disable_multisource) { bundler_3_mode? }
- settings_flag(:error_on_stderr) { bundler_2_mode? }
settings_flag(:forget_cli_options) { bundler_3_mode? }
- settings_flag(:global_path_appends_ruby_scope) { bundler_3_mode? }
settings_flag(:global_gem_cache) { bundler_3_mode? }
settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:print_only_version_number) { bundler_3_mode? }
settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
- settings_flag(:skip_default_git_sources) { bundler_4_mode? }
+ settings_flag(:skip_default_git_sources) { bundler_3_mode? }
settings_flag(:specific_platform) { bundler_3_mode? }
settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
settings_flag(:unlock_source_unlocks_spec) { !bundler_3_mode? }
@@ -54,8 +52,6 @@ module Bundler
settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
- settings_method(:github_https?, "github.https") { bundler_2_mode? }
-
def initialize(bundler_version)
@bundler_version = Gem::Version.create(bundler_version)
end
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 8397f7b72b..d21baf659d 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/vendored_persistent"
+require_relative "vendored_persistent"
require "cgi"
require "securerandom"
require "zlib"
@@ -9,10 +9,10 @@ require "rubygems/request"
module Bundler
# Handles all the fetching with the rubygems server
class Fetcher
- autoload :CompactIndex, "bundler/fetcher/compact_index"
- autoload :Downloader, "bundler/fetcher/downloader"
- autoload :Dependency, "bundler/fetcher/dependency"
- autoload :Index, "bundler/fetcher/index"
+ autoload :CompactIndex, File.expand_path("fetcher/compact_index", __dir__)
+ autoload :Downloader, File.expand_path("fetcher/downloader", __dir__)
+ autoload :Dependency, File.expand_path("fetcher/dependency", __dir__)
+ autoload :Index, File.expand_path("fetcher/index", __dir__)
# This error is raised when it looks like the network is down
class NetworkDownError < HTTPError; end
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index a117af72fa..f36d76d4ae 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require "bundler/fetcher/base"
-require "bundler/worker"
+require_relative "base"
+require_relative "../worker"
module Bundler
- autoload :CompactIndexClient, "bundler/compact_index_client"
+ autoload :CompactIndexClient, File.expand_path("../compact_index_client", __dir__)
class Fetcher
class CompactIndex < Base
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
index 1430d1ebeb..c52c32fb5b 100644
--- a/lib/bundler/fetcher/dependency.rb
+++ b/lib/bundler/fetcher/dependency.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/fetcher/base"
+require_relative "base"
require "cgi"
module Bundler
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
index 2aeb9962c4..73f125af91 100644
--- a/lib/bundler/fetcher/downloader.rb
+++ b/lib/bundler/fetcher/downloader.rb
@@ -37,6 +37,7 @@ module Bundler
when Net::HTTPTooManyRequests
raise TooManyRequestsError, response.body
when Net::HTTPUnauthorized
+ raise BadAuthenticationError, uri.host if uri.userinfo
raise AuthenticationRequiredError, uri.host
when Net::HTTPNotFound
raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}"
diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb
index 1a8064624d..9beb0e27d8 100644
--- a/lib/bundler/fetcher/index.rb
+++ b/lib/bundler/fetcher/index.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/fetcher/base"
+require_relative "base"
require "rubygems/remote_fetcher"
module Bundler
@@ -13,6 +13,7 @@ module Bundler
when /certificate verify failed/
raise CertificateFailureError.new(display_uri)
when /401/
+ raise BadAuthenticationError, remote_uri if remote_uri.userinfo
raise AuthenticationRequiredError, remote_uri
when /403/
raise BadAuthenticationError, remote_uri if remote_uri.userinfo
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index dd9b847f10..b93ae68012 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
require "cgi"
-require "bundler/vendored_thor"
+require_relative "vendored_thor"
module Bundler
module FriendlyErrors
- module_function
+ module_function # rubocop:disable Layout/AccessModifierIndentation
def log_error(error)
case error
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index e9ee03b8a2..33f1d51592 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require "bundler/vendored_thor" unless defined?(Thor)
-require "bundler"
+require_relative "vendored_thor" unless defined?(Thor)
+require_relative "../bundler"
require "shellwords"
module Bundler
diff --git a/lib/bundler/gem_tasks.rb b/lib/bundler/gem_tasks.rb
index f736517bd7..bc725d3602 100644
--- a/lib/bundler/gem_tasks.rb
+++ b/lib/bundler/gem_tasks.rb
@@ -3,5 +3,5 @@
require "rake/clean"
CLOBBER.include "pkg"
-require "bundler/gem_helper"
+require_relative "gem_helper"
Bundler::GemHelper.install_tasks
diff --git a/lib/bundler/gem_version_promoter.rb b/lib/bundler/gem_version_promoter.rb
index ed950ad28b..311b0cbbf3 100644
--- a/lib/bundler/gem_version_promoter.rb
+++ b/lib/bundler/gem_version_promoter.rb
@@ -81,8 +81,8 @@ module Bundler
sort_dep_specs(spec_groups, locked_spec)
end.tap do |specs|
if DEBUG
- STDERR.puts before_result
- STDERR.puts " after sort_versions: #{debug_format_result(dep, specs).inspect}"
+ warn before_result
+ warn " after sort_versions: #{debug_format_result(dep, specs).inspect}"
end
end
end
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb
index e67469f2dd..2cdda578e2 100644
--- a/lib/bundler/injector.rb
+++ b/lib/bundler/injector.rb
@@ -111,8 +111,10 @@ module Bundler
end
source = ", :source => \"#{d.source}\"" unless d.source.nil?
+ git = ", :git => \"#{d.git}\"" unless d.git.nil?
+ branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
- %(gem #{name}#{requirement}#{group}#{source})
+ %(gem #{name}#{requirement}#{group}#{source}#{git}#{branch})
end.join("\n")
end
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index 93355c9460..317bf892ab 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/compatibility_guard"
+require_relative "compatibility_guard"
# Allows for declaring a Gemfile inline in a ruby script, optionally installing
# any gems that aren't already installed on the user's system.
@@ -32,7 +32,7 @@ require "bundler/compatibility_guard"
# puts Pod::VERSION # => "0.34.4"
#
def gemfile(install = false, options = {}, &gemfile)
- require "bundler"
+ require_relative "../bundler"
opts = options.dup
ui = opts.delete(:ui) { Bundler::UI::Shell.new }
@@ -49,26 +49,28 @@ def gemfile(install = false, options = {}, &gemfile)
builder = Bundler::Dsl.new
builder.instance_eval(&gemfile)
- definition = builder.to_definition(nil, true)
- def definition.lock(*); end
- definition.validate_runtime!
+ Bundler.settings.temporary(:frozen => false) do
+ definition = builder.to_definition(nil, true)
+ def definition.lock(*); end
+ definition.validate_runtime!
- missing_specs = proc do
- definition.missing_specs?
- end
+ missing_specs = proc do
+ definition.missing_specs?
+ end
- Bundler.ui = ui if install
- if install || missing_specs.call
- Bundler.settings.temporary(:inline => true) do
- installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
- installer.post_install_messages.each do |name, message|
- Bundler.ui.info "Post-install message from #{name}:\n#{message}"
+ Bundler.ui = ui if install
+ if install || missing_specs.call
+ Bundler.settings.temporary(:inline => true, :disable_platform_warnings => true) do
+ installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
+ installer.post_install_messages.each do |name, message|
+ Bundler.ui.info "Post-install message from #{name}:\n#{message}"
+ end
end
end
- end
- runtime = Bundler::Runtime.new(nil, definition)
- runtime.setup.require
+ runtime = Bundler::Runtime.new(nil, definition)
+ runtime.setup.require
+ end
ensure
bundler_module = class << Bundler; self; end
bundler_module.send(:define_method, :root, old_root) if old_root
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 49143b38f9..5bc53a8b61 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -2,10 +2,10 @@
require "erb"
require "rubygems/dependency_installer"
-require "bundler/worker"
-require "bundler/installer/parallel_installer"
-require "bundler/installer/standalone"
-require "bundler/installer/gem_installer"
+require_relative "worker"
+require_relative "installer/parallel_installer"
+require_relative "installer/standalone"
+require_relative "installer/gem_installer"
module Bundler
class Installer
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index 469b15b96c..391540af0b 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require "bundler/worker"
-require "bundler/installer/gem_installer"
+require_relative "../worker"
+require_relative "gem_installer"
module Bundler
class ParallelInstaller
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 69a721c120..cbd04b2c90 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require "uri"
-require "bundler/match_platform"
+require_relative "match_platform"
module Bundler
class LazySpecification
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 50dc1381fe..5658ec1205 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -101,17 +101,11 @@ module Bundler
return unless bundler_version
prerelease_text = bundler_version.prerelease? ? " --pre" : ""
current_version = Gem::Version.create(Bundler::VERSION)
- case current_version.segments.first <=> bundler_version.segments.first
- when -1
- raise LockfileError, "You must use Bundler #{bundler_version.segments.first} or greater with this lockfile."
- when 0
- if current_version < bundler_version
- Bundler.ui.warn "Warning: the running version of Bundler (#{current_version}) is older " \
- "than the version that created the lockfile (#{bundler_version}). We suggest you to " \
- "upgrade to the version that created the lockfile by running `gem install " \
- "bundler:#{bundler_version}#{prerelease_text}`.\n"
- end
- end
+ return unless current_version < bundler_version
+ Bundler.ui.warn "Warning: the running version of Bundler (#{current_version}) is older " \
+ "than the version that created the lockfile (#{bundler_version}). We suggest you to " \
+ "upgrade to the version that created the lockfile by running `gem install " \
+ "bundler:#{bundler_version}#{prerelease_text}`.\n"
end
private
diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb
index 56cbbfb95d..69074925a6 100644
--- a/lib/bundler/match_platform.rb
+++ b/lib/bundler/match_platform.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/gem_helpers"
+require_relative "gem_helpers"
module Bundler
module MatchPlatform
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index 996d29aafb..ffb3ee9883 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/plugin/api"
+require_relative "plugin/api"
module Bundler
module Plugin
@@ -256,7 +256,7 @@ module Bundler
@hooks_by_event = Hash.new {|h, k| h[k] = [] }
load_paths = spec.load_paths
- add_to_load_path(load_paths)
+ Bundler.rubygems.add_to_load_path(load_paths)
path = Pathname.new spec.full_gem_path
begin
@@ -288,7 +288,7 @@ module Bundler
# done to avoid conflicts
path = index.plugin_path(name)
- add_to_load_path(index.load_paths(name))
+ Bundler.rubygems.add_to_load_path(index.load_paths(name))
load path.join(PLUGIN_FILE_NAME)
@@ -298,17 +298,8 @@ module Bundler
raise
end
- def add_to_load_path(load_paths)
- if insert_index = Bundler.rubygems.load_path_insert_index
- $LOAD_PATH.insert(insert_index, *load_paths)
- else
- $LOAD_PATH.unshift(*load_paths)
- end
- end
-
class << self
- private :load_plugin, :register_plugin, :save_plugins, :validate_plugin!,
- :add_to_load_path
+ private :load_plugin, :register_plugin, :save_plugins, :validate_plugin!
end
end
end
diff --git a/lib/bundler/plugin/api.rb b/lib/bundler/plugin/api.rb
index a2d5cbb4ac..ee2bffe3ab 100644
--- a/lib/bundler/plugin/api.rb
+++ b/lib/bundler/plugin/api.rb
@@ -23,7 +23,7 @@ module Bundler
# and hooks).
module Plugin
class API
- autoload :Source, "bundler/plugin/api/source"
+ autoload :Source, File.expand_path("api/source", __dir__)
# The plugins should declare that they handle a command through this helper.
#
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
index faabf3a8d1..2d70a046bb 100644
--- a/lib/bundler/plugin/index.rb
+++ b/lib/bundler/plugin/index.rb
@@ -139,7 +139,7 @@ module Bundler
data = index_f.read
- require "bundler/yaml_serializer"
+ require_relative "../yaml_serializer"
index = YAMLSerializer.load(data)
@commands.merge!(index["commands"])
@@ -162,7 +162,7 @@ module Bundler
"sources" => @sources,
}
- require "bundler/yaml_serializer"
+ require_relative "../yaml_serializer"
SharedHelpers.filesystem_access(index_file) do |index_f|
FileUtils.mkdir_p(index_f.dirname)
File.open(index_f, "w") {|f| f.puts YAMLSerializer.dump(index) }
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 4a262efac2..bcea3f0e45 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -8,8 +8,8 @@ module Bundler
# are heavily dependent on the Gemfile.
module Plugin
class Installer
- autoload :Rubygems, "bundler/plugin/installer/rubygems"
- autoload :Git, "bundler/plugin/installer/git"
+ autoload :Rubygems, File.expand_path("installer/rubygems", __dir__)
+ autoload :Git, File.expand_path("installer/git", __dir__)
def install(names, options)
check_sources_consistency!(options)
diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb
index e654416a5a..c086b7651c 100644
--- a/lib/bundler/psyched_yaml.rb
+++ b/lib/bundler/psyched_yaml.rb
@@ -27,7 +27,7 @@ module Bundler
end
end
-require "bundler/deprecate"
+require_relative "deprecate"
begin
Bundler::Deprecate.skip_during do
require "rubygems/safe_yaml"
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 90f833bef1..c7caf01c7d 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -2,8 +2,8 @@
module Bundler
class Resolver
- require "bundler/vendored_molinillo"
- require "bundler/resolver/spec_group"
+ require_relative "vendored_molinillo"
+ require_relative "resolver/spec_group"
# Figures out the best possible configuration of gems that satisfies
# the list of passed dependencies and any child dependencies without
@@ -75,7 +75,7 @@ module Bundler
return unless debug?
debug_info = yield
debug_info = debug_info.inspect unless debug_info.is_a?(String)
- STDERR.puts debug_info.split("\n").map {|s| " " * depth + s }
+ warn debug_info.split("\n").map {|s| " " * depth + s }
end
def debug?
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index ccf71c8c00..96b93836c7 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -4,40 +4,25 @@ require "pathname"
require "rubygems/specification"
-begin
- # Possible use in Gem::Specification#source below and require
- # shouldn't be deferred.
- require "rubygems/source"
-rescue LoadError
- # Not available before RubyGems 2.0.0, ignore
- nil
-end
+# Possible use in Gem::Specification#source below and require
+# shouldn't be deferred.
+require "rubygems/source"
-require "bundler/match_platform"
+require_relative "match_platform"
module Gem
- @loaded_stacks = Hash.new {|h, k| h[k] = [] }
-
class Specification
attr_accessor :remote, :location, :relative_loaded_from
- if instance_methods(false).include?(:source)
- remove_method :source
- attr_writer :source
- def source
- (defined?(@source) && @source) || Gem::Source::Installed.new
- end
- else
- # rubocop:disable Lint/DuplicateMethods
- attr_accessor :source
- # rubocop:enable Lint/DuplicateMethods
+ remove_method :source
+ attr_writer :source
+ def source
+ (defined?(@source) && @source) || Gem::Source::Installed.new
end
alias_method :rg_full_gem_path, :full_gem_path
alias_method :rg_loaded_from, :loaded_from
- attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
-
def full_gem_path
# this cannot check source.is_a?(Bundler::Plugin::API::Source)
# because that _could_ trip the autoload, and if there are unresolved
@@ -59,15 +44,7 @@ module Gem
end
def load_paths
- return full_require_paths if respond_to?(:full_require_paths)
-
- require_paths.map do |require_path|
- if require_path.include?(full_gem_path)
- require_path
- else
- File.join(full_gem_path, require_path)
- end
- end
+ full_require_paths
end
if method_defined?(:extension_dir)
@@ -151,32 +128,6 @@ module Gem
end
out
end
-
- # Backport of performance enhancement added to RubyGems 1.4
- def matches_spec?(spec)
- # name can be a Regexp, so use ===
- return false unless name === spec.name
- return true if requirement.none?
-
- requirement.satisfied_by?(spec.version)
- end unless allocate.respond_to?(:matches_spec?)
- end
-
- class Requirement
- # Backport of performance enhancement added to RubyGems 1.4
- def none?
- # note that it might be tempting to replace with with RubyGems 2.0's
- # improved implementation. Don't. It requires `DefaultRequirement` to be
- # defined, and more importantantly, these overrides are not used when the
- # running RubyGems defines these methods
- to_s == ">= 0"
- end unless allocate.respond_to?(:none?)
-
- # Backport of performance enhancement added to RubyGems 2.2
- def exact?
- return false unless @requirements.size == 1
- @requirements[0][0] == "="
- end unless allocate.respond_to?(:exact?)
end
class Platform
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index a4519246a9..9df0897ca2 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require "monitor"
-
module Bundler
class RubygemsIntegration
if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
else
+ require "monitor"
+
EXT_LOCK = Monitor.new
end
@@ -20,6 +20,7 @@ module Bundler
def initialize
@replaced_methods = {}
+ backport_ext_builder_monitor
end
def version
@@ -38,14 +39,22 @@ module Bundler
Gem::Command.build_args = args
end
- def load_path_insert_index
- Gem.load_path_insert_index
- end
-
def loaded_specs(name)
Gem.loaded_specs[name]
end
+ def add_to_load_path(paths)
+ return Gem.add_to_load_path(*paths) if Gem.respond_to?(:add_to_load_path)
+
+ if insert_index = Gem.load_path_insert_index
+ # Gem directories must come after -I and ENV['RUBYLIB']
+ $LOAD_PATH.insert(insert_index, *paths)
+ else
+ # We are probably testing in core, -I and RUBYLIB don't apply
+ $LOAD_PATH.unshift(*paths)
+ end
+ end
+
def mark_loaded(spec)
if spec.respond_to?(:activated=)
current = Gem.loaded_specs[spec.name]
@@ -110,7 +119,7 @@ module Bundler
end
def configuration
- require "bundler/psyched_yaml"
+ require_relative "psyched_yaml"
Gem.configuration
rescue Gem::SystemExitException, LoadError => e
Bundler.ui.error "#{e.class}: #{e.message}"
@@ -198,10 +207,6 @@ module Bundler
Gem::ConfigMap
end
- def repository_subdirectories
- %w[cache doc gems specifications]
- end
-
def clear_paths
Gem.clear_paths
end
@@ -210,26 +215,14 @@ module Bundler
Gem.bin_path(gem, bin, ver)
end
- def path_separator
- File::PATH_SEPARATOR
- end
-
def preserve_paths
# this is a no-op outside of RubyGems 1.8
yield
end
def loaded_gem_paths
- # RubyGems 2.2+ can put binary extension into dedicated folders,
- # therefore use RubyGems facilities to obtain their load paths.
- if Gem::Specification.method_defined? :full_require_paths
- loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
- loaded_gem_paths.flatten
- else
- $LOAD_PATH.select do |p|
- Bundler.rubygems.gem_path.any? {|gp| p =~ /^#{Regexp.escape(gp)}/ }
- end
- end
+ loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
+ loaded_gem_paths.flatten
end
def load_plugins
@@ -248,36 +241,12 @@ module Bundler
EXT_LOCK
end
- def fetch_specs(all, pre, &blk)
- require "rubygems/spec_fetcher"
- specs = Gem::SpecFetcher.new.list(all, pre)
- specs.each { yield } if block_given?
- specs
- end
-
def fetch_prerelease_specs
fetch_specs(false, true)
rescue Gem::RemoteFetcher::FetchError
{} # if we can't download them, there aren't any
end
- # TODO: This is for older versions of RubyGems... should we support the
- # X-Gemfile-Source header on these old versions?
- # Maybe the newer implementation will work on older RubyGems?
- # It seems difficult to keep this implementation and still send the header.
- def fetch_all_remote_specs(remote)
- old_sources = Bundler.rubygems.sources
- Bundler.rubygems.sources = [remote.uri.to_s]
- # Fetch all specs, minus prerelease specs
- spec_list = fetch_specs(true, false)
- # Then fetch the prerelease specs
- fetch_prerelease_specs.each {|k, v| spec_list[k].concat(v) }
-
- spec_list.values.first
- ensure
- Bundler.rubygems.sources = old_sources
- end
-
def with_build_args(args)
ext_lock.synchronize do
old_args = build_args
@@ -290,18 +259,9 @@ module Bundler
end
end
- def install_with_build_args(args)
- with_build_args(args) { yield }
- end
-
- def gem_from_path(path, policy = nil)
- require "rubygems/format"
- Gem::Format.from_file_by_path(path, policy)
- end
-
def spec_from_gem(path, policy = nil)
require "rubygems/security"
- require "bundler/psyched_yaml"
+ require_relative "psyched_yaml"
gem_from_path(path, security_policies[policy]).spec
rescue Gem::Package::FormatError
raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
@@ -317,23 +277,10 @@ module Bundler
end
end
- def build(spec, skip_validation = false)
- require "rubygems/builder"
- Gem::Builder.new(spec).build
- end
-
def build_gem(gem_dir, spec)
build(spec)
end
- def download_gem(spec, uri, path)
- uri = Bundler.settings.mirror_for(uri)
- fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
- Bundler::Retry.new("download gem from #{uri}").attempts do
- fetcher.download(spec, uri, path)
- end
- end
-
def security_policy_keys
%w[High Medium Low AlmostNo No].map {|level| "#{level}Security" }
end
@@ -357,12 +304,17 @@ module Bundler
end
end
+ # RubyGems-generated binstubs call Kernel#gem
def binstubs_call_gem?
- true
+ !provides?(">= 2.5.2")
end
+ # only 2.5.2+ has all of the stub methods we want to use, and since this
+ # is a performance optimization _only_,
+ # we'll restrict ourselves to the most
+ # recent RG versions instead of all versions that have stubs
def stubs_provide_full_functionality?
- false
+ provides?(">= 2.5.2")
end
def replace_gem(specs, specs_by_name)
@@ -411,26 +363,6 @@ module Bundler
end
end
- def stub_source_index(specs)
- Gem::SourceIndex.send(:alias_method, :old_initialize, :initialize)
- redefine_method(Gem::SourceIndex, :initialize) do |*args|
- @gems = {}
- # You're looking at this thinking: Oh! This is how I make those
- # rubygems deprecations go away!
- #
- # You'd be correct BUT using of this method in production code
- # must be approved by the rubygems team itself!
- #
- # This is your warning. If you use this and don't have approval
- # we can't protect you.
- #
- Deprecate.skip_during do
- self.spec_dirs = *args
- add_specs(*specs)
- end
- end
- end
-
# Used to make bin stubs that are not created by bundler work
# under bundler. The new Gem.bin_path only considers gems in
# +specs+
@@ -531,25 +463,6 @@ module Bundler
Gem.clear_paths
end
- # This backports the correct segment generation code from RubyGems 1.4+
- # by monkeypatching it into the method in RubyGems 1.3.6 and 1.3.7.
- def backport_segment_generation
- redefine_method(Gem::Version, :segments) do
- @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
- /^\d+$/ =~ s ? s.to_i : s
- end
- end
- end
-
- # This backport fixes the marshaling of @segments.
- def backport_yaml_initialize
- redefine_method(Gem::Version, :yaml_initialize) do |_, map|
- @version = map["version"]
- @segments = nil
- @hash = nil
- end
- end
-
# This backports base_dir which replaces installation path
# RubyGems 1.8+
def backport_base_dir
@@ -622,296 +535,129 @@ module Bundler
end
end
- # RubyGems 1.4 through 1.6
- class Legacy < RubygemsIntegration
- def initialize
- super
- backport_base_dir
- backport_cache_file
- backport_spec_file
- backport_yaml_initialize
- end
+ def stub_rubygems(specs)
+ Gem::Specification.all = specs
- def stub_rubygems(specs)
- # RubyGems versions lower than 1.7 use SourceIndex#from_gems_in
- source_index_class = (class << Gem::SourceIndex; self; end)
- redefine_method(source_index_class, :from_gems_in) do |*args|
- Gem::SourceIndex.new.tap do |source_index|
- source_index.spec_dirs = *args
- source_index.add_specs(*specs)
- end
- end
+ Gem.post_reset do
+ Gem::Specification.all = specs
end
- def all_specs
- Gem.source_index.gems.values
+ redefine_method((class << Gem; self; end), :finish_resolve) do |*|
+ []
end
+ end
- def find_name(name)
- Gem.source_index.find_name(name)
- end
+ def fetch_specs(source, remote, name)
+ path = source + "#{name}.#{Gem.marshal_version}.gz"
+ fetcher = gem_remote_fetcher
+ fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
+ string = fetcher.fetch_path(path)
+ Bundler.load_marshal(string)
+ rescue Gem::RemoteFetcher::FetchError => e
+ # it's okay for prerelease to fail
+ raise e unless name == "prerelease_specs"
+ end
- def validate(spec)
- # These versions of RubyGems always validate in "packaging" mode,
- # which is too strict for the kinds of checks we care about. As a
- # result, validation is disabled on versions of RubyGems below 1.7.
- end
+ def fetch_all_remote_specs(remote)
+ source = remote.uri.is_a?(URI) ? remote.uri : URI.parse(source.to_s)
- def post_reset_hooks
- []
- end
+ specs = fetch_specs(source, remote, "specs")
+ pres = fetch_specs(source, remote, "prerelease_specs") || []
- def reset
- end
+ specs.concat(pres)
end
- # RubyGems versions 1.3.6 and 1.3.7
- class Ancient < Legacy
- def initialize
- super
- backport_segment_generation
+ def download_gem(spec, uri, path)
+ uri = Bundler.settings.mirror_for(uri)
+ fetcher = gem_remote_fetcher
+ fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
+ Bundler::Retry.new("download gem from #{uri}").attempts do
+ fetcher.download(spec, uri, path)
end
end
- # RubyGems 1.7
- class Transitional < Legacy
- def stub_rubygems(specs)
- stub_source_index(specs)
- end
-
- def validate(spec)
- # Missing summary is downgraded to a warning in later versions,
- # so we set it to an empty string to prevent an exception here.
- spec.summary ||= ""
- RubygemsIntegration.instance_method(:validate).bind(self).call(spec)
- end
+ def gem_remote_fetcher
+ require "resolv"
+ proxy = configuration[:http_proxy]
+ dns = Resolv::DNS.new
+ Bundler::GemRemoteFetcher.new(proxy, dns)
end
- # RubyGems 1.8.5-1.8.19
- class Modern < RubygemsIntegration
- def stub_rubygems(specs)
- Gem::Specification.all = specs
-
- Gem.post_reset do
- Gem::Specification.all = specs
- end
+ def gem_from_path(path, policy = nil)
+ require "rubygems/package"
+ p = Gem::Package.new(path)
+ p.security_policy = policy if policy
+ p
+ end
- stub_source_index(specs)
- end
+ def build(spec, skip_validation = false)
+ require "rubygems/package"
+ Gem::Package.build(spec, skip_validation)
+ end
- def all_specs
- Gem::Specification.to_a
- end
+ def repository_subdirectories
+ Gem::REPOSITORY_SUBDIRECTORIES
+ end
- def find_name(name)
- Gem::Specification.find_all_by_name name
- end
+ def install_with_build_args(args)
+ yield
end
- # RubyGems 1.8.0 to 1.8.4
- class AlmostModern < Modern
- # RubyGems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
- # you call Gem::Installer#install with an :install_dir set. We have to
- # change it back for our sudo mode to work.
- def preserve_paths
- old_dir = gem_dir
- old_path = gem_path
- yield
- Gem.use_paths(old_dir, old_path)
- end
+ def path_separator
+ Gem.path_separator
end
- # RubyGems 1.8.20+
- class MoreModern < Modern
- # RubyGems 1.8.20 and adds the skip_validation parameter, so that's
- # when we start passing it through.
- def build(spec, skip_validation = false)
- require "rubygems/builder"
- Gem::Builder.new(spec).build(skip_validation)
+ def all_specs
+ require_relative "remote_specification"
+ Gem::Specification.stubs.map do |stub|
+ StubSpecification.from_stub(stub)
end
end
- # RubyGems 2.0
- class Future < RubygemsIntegration
- def stub_rubygems(specs)
- Gem::Specification.all = specs
-
- Gem.post_reset do
- Gem::Specification.all = specs
+ def backport_ext_builder_monitor
+ # So we can avoid requiring "rubygems/ext" in its entirety
+ Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
+ module Ext
end
+ RB
- redefine_method((class << Gem; self; end), :finish_resolve) do |*|
- []
- end
- end
-
- def all_specs
- Gem::Specification.to_a
- end
-
- def find_name(name)
- Gem::Specification.find_all_by_name name
- end
-
- def fetch_specs(source, remote, name)
- path = source + "#{name}.#{Gem.marshal_version}.gz"
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
- string = fetcher.fetch_path(path)
- Bundler.load_marshal(string)
- rescue Gem::RemoteFetcher::FetchError => e
- # it's okay for prerelease to fail
- raise e unless name == "prerelease_specs"
- end
-
- def fetch_all_remote_specs(remote)
- source = remote.uri.is_a?(URI) ? remote.uri : URI.parse(source.to_s)
+ require "rubygems/ext/builder"
- specs = fetch_specs(source, remote, "specs")
- pres = fetch_specs(source, remote, "prerelease_specs") || []
-
- specs.concat(pres)
- end
-
- def download_gem(spec, uri, path)
- uri = Bundler.settings.mirror_for(uri)
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
- Bundler::Retry.new("download gem from #{uri}").attempts do
- fetcher.download(spec, uri, path)
+ Gem::Ext::Builder.class_eval do
+ unless const_defined?(:CHDIR_MONITOR)
+ const_set(:CHDIR_MONITOR, EXT_LOCK)
end
- end
-
- def gem_remote_fetcher
- require "resolv"
- proxy = configuration[:http_proxy]
- dns = Resolv::DNS.new
- Bundler::GemRemoteFetcher.new(proxy, dns)
- end
-
- def gem_from_path(path, policy = nil)
- require "rubygems/package"
- p = Gem::Package.new(path)
- p.security_policy = policy if policy
- p
- end
- def build(spec, skip_validation = false)
- require "rubygems/package"
- Gem::Package.build(spec, skip_validation)
- end
-
- def repository_subdirectories
- Gem::REPOSITORY_SUBDIRECTORIES
- end
-
- def install_with_build_args(args)
- yield
- end
-
- def path_separator
- Gem.path_separator
+ remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
+ const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
end
end
- # RubyGems 2.1.0
- class MoreFuture < Future
- def initialize
- super
- backport_ext_builder_monitor
- end
-
- def all_specs
- require "bundler/remote_specification"
- Gem::Specification.stubs.map do |stub|
- StubSpecification.from_stub(stub)
- end
- end
-
- def backport_ext_builder_monitor
- # So we can avoid requiring "rubygems/ext" in its entirety
- Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
- module Ext
- end
- RB
-
- require "rubygems/ext/builder"
-
- Gem::Ext::Builder.class_eval do
- unless const_defined?(:CHDIR_MONITOR)
- const_set(:CHDIR_MONITOR, EXT_LOCK)
- end
-
- remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
- const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
- end
- end
-
- if Gem::Specification.respond_to?(:stubs_for)
- def find_name(name)
- Gem::Specification.stubs_for(name).map(&:to_spec)
- end
- else
- def find_name(name)
- Gem::Specification.stubs.find_all do |spec|
- spec.name == name
- end.map(&:to_spec)
- end
- end
+ def find_name(name)
+ Gem::Specification.stubs_for(name).map(&:to_spec)
+ end
- if Gem::Specification.respond_to?(:default_stubs)
- def default_stubs
- Gem::Specification.default_stubs("*.gemspec")
- end
- else
- def default_stubs
- Gem::Specification.send(:default_stubs, "*.gemspec")
- end
+ if Gem::Specification.respond_to?(:default_stubs)
+ def default_stubs
+ Gem::Specification.default_stubs("*.gemspec")
end
-
- def use_gemdeps(gemfile)
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
- require "bundler/gemdeps"
- runtime = Bundler.setup
- Bundler.ui = nil
- activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
- [Gemdeps.new(runtime), activated_spec_names]
+ else
+ def default_stubs
+ Gem::Specification.send(:default_stubs, "*.gemspec")
end
+ end
- if provides?(">= 2.5.2")
- # RubyGems-generated binstubs call Kernel#gem
- def binstubs_call_gem?
- false
- end
-
- # only 2.5.2+ has all of the stub methods we want to use, and since this
- # is a performance optimization _only_,
- # we'll restrict ourselves to the most
- # recent RG versions instead of all versions that have stubs
- def stubs_provide_full_functionality?
- true
- end
- end
+ def use_gemdeps(gemfile)
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
+ require_relative "gemdeps"
+ runtime = Bundler.setup
+ Bundler.ui = nil
+ activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
+ [Gemdeps.new(runtime), activated_spec_names]
end
end
def self.rubygems
- @rubygems ||= if RubygemsIntegration.provides?(">= 2.1.0")
- RubygemsIntegration::MoreFuture.new
- elsif RubygemsIntegration.provides?(">= 1.99.99")
- RubygemsIntegration::Future.new
- elsif RubygemsIntegration.provides?(">= 1.8.20")
- RubygemsIntegration::MoreModern.new
- elsif RubygemsIntegration.provides?(">= 1.8.5")
- RubygemsIntegration::Modern.new
- elsif RubygemsIntegration.provides?(">= 1.8.0")
- RubygemsIntegration::AlmostModern.new
- elsif RubygemsIntegration.provides?(">= 1.7.0")
- RubygemsIntegration::Transitional.new
- elsif RubygemsIntegration.provides?(">= 1.4.0")
- RubygemsIntegration::Legacy.new
- else # RubyGems 1.3.6 and 1.3.7
- RubygemsIntegration::Ancient.new
- end
+ @rubygems ||= RubygemsIntegration.new
end
end
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 83945868f9..93a801eb6c 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -34,14 +34,7 @@ module Bundler
spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
end.reverse.flatten
- # See Gem::Specification#add_self_to_load_path (since RubyGems 1.8)
- if insert_index = Bundler.rubygems.load_path_insert_index
- # Gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(insert_index, *load_paths)
- else
- # We are probably testing in core, -I and RUBYLIB don't apply
- $LOAD_PATH.unshift(*load_paths)
- end
+ Bundler.rubygems.add_to_load_path(load_paths)
setup_manpath
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 5bc190865f..3888ac51d3 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -4,9 +4,9 @@ require "uri"
module Bundler
class Settings
- autoload :Mirror, "bundler/mirror"
- autoload :Mirrors, "bundler/mirror"
- autoload :Validator, "bundler/settings/validator"
+ autoload :Mirror, File.expand_path("mirror", __dir__)
+ autoload :Mirrors, File.expand_path("mirror", __dir__)
+ autoload :Validator, File.expand_path("settings/validator", __dir__)
BOOL_KEYS = %w[
allow_bundler_dependency_conflicts
@@ -28,14 +28,11 @@ module Bundler
disable_platform_warnings
disable_shared_gems
disable_version_check
- error_on_stderr
force_ruby_platform
forget_cli_options
frozen
gem.coc
gem.mit
- github.https
- global_path_appends_ruby_scope
global_gem_cache
ignore_messages
init_gems_rb
@@ -207,23 +204,22 @@ module Bundler
locations
end
- # for legacy reasons, in Bundler 1, the ruby scope isnt appended when the setting comes from ENV or the global config,
- # nor do we respect :disable_shared_gems
+ # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
def path
key = key_for(:path)
path = ENV[key] || @global_config[key]
if path && !@temporary.key?(key) && !@local_config.key?(key)
- return Path.new(path, Bundler.feature_flag.global_path_appends_ruby_scope?, false, false)
+ return Path.new(path, false, false)
end
system_path = self["path.system"] || (self[:disable_shared_gems] == false)
- Path.new(self[:path], true, system_path, Bundler.feature_flag.default_install_uses_path?)
+ Path.new(self[:path], system_path, Bundler.feature_flag.default_install_uses_path?)
end
- Path = Struct.new(:explicit_path, :append_ruby_scope, :system_path, :default_install_uses_path) do
+ Path = Struct.new(:explicit_path, :system_path, :default_install_uses_path) do
def path
path = base_path
- path = File.join(path, Bundler.ruby_scope) if append_ruby_scope && !use_system_gems?
+ path = File.join(path, Bundler.ruby_scope) unless use_system_gems?
path
end
@@ -358,7 +354,7 @@ module Bundler
return unless file
SharedHelpers.filesystem_access(file) do |p|
FileUtils.mkdir_p(p.dirname)
- require "bundler/yaml_serializer"
+ require_relative "yaml_serializer"
p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
end
end
@@ -398,7 +394,7 @@ module Bundler
SharedHelpers.filesystem_access(config_file, :read) do |file|
valid_file = file.exist? && !file.size.zero?
return {} unless valid_file
- require "bundler/yaml_serializer"
+ require_relative "yaml_serializer"
YAMLSerializer.load file.read
end
end
diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb
index 52a5b8889a..d156f494a8 100644
--- a/lib/bundler/setup.rb
+++ b/lib/bundler/setup.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require "bundler/shared_helpers"
+require_relative "shared_helpers"
if Bundler::SharedHelpers.in_bundle?
- require "bundler"
+ require_relative "../bundler"
if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
Bundler.ui = Bundler::UI::Shell.new
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 1b703c5cbc..d259f20e6b 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require "bundler/compatibility_guard"
+require_relative "compatibility_guard"
require "pathname"
require "rbconfig"
require "rubygems"
-require "bundler/version"
-require "bundler/constants"
-require "bundler/rubygems_integration"
-require "bundler/current_ruby"
+require_relative "version"
+require_relative "constants"
+require_relative "rubygems_integration"
+require_relative "current_ruby"
module Bundler
module SharedHelpers
@@ -103,9 +103,7 @@ module Bundler
#
# @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block)
- # Use block.call instead of yield because of a bug in Ruby 2.2.2
- # See https://github.com/bundler/bundler/issues/5341 for details
- block.call(path.dup.untaint)
+ yield(path.dup.untaint)
rescue Errno::EACCES
raise PermissionError.new(path, action)
rescue Errno::EAGAIN
@@ -132,7 +130,7 @@ module Bundler
def major_deprecation(major_version, message)
bundler_major_version = Bundler.bundler_major_version
if bundler_major_version > major_version
- require "bundler/errors"
+ require_relative "errors"
raise DeprecatedError, "[REMOVED] #{message}"
end
@@ -289,20 +287,10 @@ module Bundler
public :set_env
def set_bundle_variables
- begin
- exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
- unless File.exist?(exe_file)
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
- end
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
- rescue Gem::GemNotFoundException
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
- # for Ruby core repository
- exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
- end
-
- # Set BUNDLE_GEMFILE
+ exe_file = File.expand_path("../../../exe/bundle", __FILE__)
+ # for Ruby core repository
+ exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s
Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
end
@@ -316,8 +304,9 @@ module Bundler
def set_rubyopt
rubyopt = [ENV["RUBYOPT"]].compact
- return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup}
- rubyopt.unshift %(-rbundler/setup)
+ setup_require = "-r#{File.expand_path("setup", __dir__)}"
+ return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
+ rubyopt.unshift %(#{setup_require})
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
end
@@ -351,9 +340,9 @@ module Bundler
end
def prints_major_deprecations?
- require "bundler"
+ require_relative "../bundler"
return false if Bundler.settings[:silence_deprecations]
- require "bundler/deprecate"
+ require_relative "deprecate"
return false if Bundler::Deprecate.skip
true
end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 26a3625bb1..4b2e305bda 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -2,11 +2,11 @@
module Bundler
class Source
- autoload :Gemspec, "bundler/source/gemspec"
- autoload :Git, "bundler/source/git"
- autoload :Metadata, "bundler/source/metadata"
- autoload :Path, "bundler/source/path"
- autoload :Rubygems, "bundler/source/rubygems"
+ autoload :Gemspec, File.expand_path("source/gemspec", __dir__)
+ autoload :Git, File.expand_path("source/git", __dir__)
+ autoload :Metadata, File.expand_path("source/metadata", __dir__)
+ autoload :Path, File.expand_path("source/path", __dir__)
+ autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
attr_accessor :dependency_names
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index a8afb341d8..ed16f4a4e0 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require "bundler/vendored_fileutils"
+require_relative "../vendored_fileutils"
require "uri"
module Bundler
class Source
class Git < Path
- autoload :GitProxy, "bundler/source/git/git_proxy"
+ autoload :GitProxy, File.expand_path("git/git_proxy", __dir__)
attr_reader :uri, :ref, :branch, :options, :submodules
diff --git a/lib/bundler/source/metadata.rb b/lib/bundler/source/metadata.rb
index 559b912ffd..0867879861 100644
--- a/lib/bundler/source/metadata.rb
+++ b/lib/bundler/source/metadata.rb
@@ -13,10 +13,13 @@ module Bundler
idx << Gem::Specification.new do |s|
s.name = "bundler"
s.version = VERSION
+ s.license = "MIT"
s.platform = Gem::Platform::RUBY
s.source = self
s.authors = ["bundler team"]
s.bindir = "exe"
+ s.homepage = "https://bundler.io"
+ s.summary = "The best way to manage your application's dependencies"
s.executables = %w[bundle]
# can't point to the actual gemspec or else the require paths will be wrong
s.loaded_from = File.expand_path("..", __FILE__)
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 5f3f1bc2e4..c1d25fc4da 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -3,7 +3,7 @@
module Bundler
class Source
class Path < Source
- autoload :Installer, "bundler/source/path/installer"
+ autoload :Installer, File.expand_path("path/installer", __dir__)
attr_reader :path, :options, :root_path, :original_path
attr_writer :name
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 86fd329089..103faa6b80 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -6,7 +6,7 @@ require "rubygems/user_interaction"
module Bundler
class Source
class Rubygems < Source
- autoload :Remote, "bundler/source/rubygems/remote"
+ autoload :Remote, File.expand_path("rubygems/remote", __dir__)
# Use the API when installing less than X gems
API_REQUEST_LIMIT = 500
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
index bef94b505e..bad69c9a14 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/remote_specification"
+require_relative "remote_specification"
module Bundler
class StubSpecification < RemoteSpecification
@@ -55,8 +55,6 @@ module Bundler
stub.full_require_paths
end
- # This is what we do in bundler/rubygems_ext
- # full_require_paths is always implemented
def load_paths
full_require_paths
end
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
index 5505540b9e..18060942c3 100644
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ b/lib/bundler/templates/newgem/newgem.gemspec.tt
@@ -1,6 +1,4 @@
-lib = File.expand_path("lib", __dir__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require "<%= config[:namespaced_path] %>/version"
+require_relative 'lib/<%=config[:namespaced_path]%>/version'
Gem::Specification.new do |spec|
spec.name = <%= config[:name].inspect %>
diff --git a/lib/bundler/ui.rb b/lib/bundler/ui.rb
index 8138b30d38..7a4fa03669 100644
--- a/lib/bundler/ui.rb
+++ b/lib/bundler/ui.rb
@@ -2,8 +2,8 @@
module Bundler
module UI
- autoload :RGProxy, "bundler/ui/rg_proxy"
- autoload :Shell, "bundler/ui/shell"
- autoload :Silent, "bundler/ui/silent"
+ autoload :RGProxy, File.expand_path("ui/rg_proxy", __dir__)
+ autoload :Shell, File.expand_path("ui/shell", __dir__)
+ autoload :Silent, File.expand_path("ui/silent", __dir__)
end
end
diff --git a/lib/bundler/ui/rg_proxy.rb b/lib/bundler/ui/rg_proxy.rb
index e2f98481db..ef6def225b 100644
--- a/lib/bundler/ui/rg_proxy.rb
+++ b/lib/bundler/ui/rg_proxy.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/ui"
+require_relative "../ui"
require "rubygems/user_interaction"
module Bundler
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 16e3d15713..8e49fa5885 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/vendored_thor"
+require_relative "../vendored_thor"
module Bundler
module UI
@@ -35,14 +35,12 @@ module Bundler
return if @warning_history.include? msg
@warning_history << msg
- return tell_err(msg, :yellow, newline) if Bundler.feature_flag.error_on_stderr?
- tell_me(msg, :yellow, newline)
+ tell_err(msg, :yellow, newline)
end
def error(msg, newline = nil)
return unless level("error")
- return tell_err(msg, :red, newline) if Bundler.feature_flag.error_on_stderr?
- tell_me(msg, :red, newline)
+ tell_err(msg, :red, newline)
end
def debug(msg, newline = nil)
diff --git a/lib/bundler/uri_credentials_filter.rb b/lib/bundler/uri_credentials_filter.rb
index ee3692268c..0f6ea4cefa 100644
--- a/lib/bundler/uri_credentials_filter.rb
+++ b/lib/bundler/uri_credentials_filter.rb
@@ -2,7 +2,7 @@
module Bundler
module URICredentialsFilter
- module_function
+ module_function # rubocop:disable Layout/AccessModifierIndentation
def credential_filtered_uri(uri_to_anonymize)
return uri_to_anonymize if uri_to_anonymize.nil?
diff --git a/lib/bundler/vendor/fileutils/lib/fileutils.rb b/lib/bundler/vendor/fileutils/lib/fileutils.rb
index fb7777eb49..6fbe741498 100644
--- a/lib/bundler/vendor/fileutils/lib/fileutils.rb
+++ b/lib/bundler/vendor/fileutils/lib/fileutils.rb
@@ -6,7 +6,7 @@ rescue LoadError
# for make mjit-headers
end
-require "bundler/vendor/fileutils/lib/fileutils/version"
+require_relative "fileutils/version"
#
# = fileutils.rb
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo.rb b/lib/bundler/vendor/molinillo/lib/molinillo.rb
index 9e2867144f..baedefe98b 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/compatibility'
-require 'bundler/vendor/molinillo/lib/molinillo/gem_metadata'
-require 'bundler/vendor/molinillo/lib/molinillo/errors'
-require 'bundler/vendor/molinillo/lib/molinillo/resolver'
-require 'bundler/vendor/molinillo/lib/molinillo/modules/ui'
-require 'bundler/vendor/molinillo/lib/molinillo/modules/specification_provider'
+require_relative 'molinillo/compatibility'
+require_relative 'molinillo/gem_metadata'
+require_relative 'molinillo/errors'
+require_relative 'molinillo/resolver'
+require_relative 'molinillo/modules/ui'
+require_relative 'molinillo/modules/specification_provider'
# Bundler::Molinillo is a generic dependency resolution algorithm.
module Bundler::Molinillo
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
index 677a8bd916..31578bb5bf 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
@@ -3,8 +3,8 @@
require 'set'
require 'tsort'
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/log'
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex'
+require_relative 'dependency_graph/log'
+require_relative 'dependency_graph/vertex'
module Bundler::Molinillo
# A directed acyclic graph that is tuned to hold named dependencies
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
index 9849aea2fe..946a08236e 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action'
+require_relative 'action'
module Bundler::Molinillo
class DependencyGraph
# @!visibility private
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
index 0a1e08255b..483527daf8 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action'
+require_relative 'action'
module Bundler::Molinillo
class DependencyGraph
# @!visibility private
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
index 1d9f4b327d..d81940585a 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action'
+require_relative 'action'
module Bundler::Molinillo
class DependencyGraph
# @!visibility private
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
index 385dcbdd06..36fce7c526 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action'
+require_relative 'action'
module Bundler::Molinillo
class DependencyGraph
# @!visibility private
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
index 8582dd19c1..6f0de19886 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular'
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex'
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge'
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named'
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload'
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag'
+require_relative 'add_edge_no_circular'
+require_relative 'add_vertex'
+require_relative 'delete_edge'
+require_relative 'detach_vertex_named'
+require_relative 'set_payload'
+require_relative 'tag'
module Bundler::Molinillo
class DependencyGraph
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb
index 37286d104a..2e9b90e6cd 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action'
+require_relative 'action'
module Bundler::Molinillo
class DependencyGraph
# @!visibility private
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb
index d6ad16e07a..fccfc78cc7 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action'
+require_relative 'action'
module Bundler::Molinillo
class DependencyGraph
# @!visibility private
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb b/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
index ce0931f103..89c7c324d5 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb
@@ -80,7 +80,7 @@ module Bundler::Molinillo
@specification_provider = specification_provider
end
- require 'bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider'
+ require_relative 'delegates/specification_provider'
include Delegates::SpecificationProvider
# @return [String] An error message that includes requirement trees,
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
index 0eb665d17a..acf7777414 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
@@ -238,11 +238,11 @@ module Bundler::Molinillo
debug { 'Activated: ' + Hash[activated.vertices.select { |_n, v| v.payload }].keys.join(', ') } if state
end
- require 'bundler/vendor/molinillo/lib/molinillo/state'
- require 'bundler/vendor/molinillo/lib/molinillo/modules/specification_provider'
+ require_relative 'state'
+ require_relative 'modules/specification_provider'
- require 'bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state'
- require 'bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider'
+ require_relative 'delegates/resolution_state'
+ require_relative 'delegates/specification_provider'
include Bundler::Molinillo::Delegates::ResolutionState
include Bundler::Molinillo::Delegates::SpecificationProvider
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
index 7d36858778..95eaab5991 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph'
+require_relative 'dependency_graph'
module Bundler::Molinillo
# This class encapsulates a dependency resolver.
@@ -9,7 +9,7 @@ module Bundler::Molinillo
#
#
class Resolver
- require 'bundler/vendor/molinillo/lib/molinillo/resolution'
+ require_relative 'resolution'
# @return [SpecificationProvider] the specification provider used
# in the resolution process
diff --git a/lib/bundler/vendor/thor/lib/thor/base.rb b/lib/bundler/vendor/thor/lib/thor/base.rb
index e79d03d087..f55b14fbfc 100644
--- a/lib/bundler/vendor/thor/lib/thor/base.rb
+++ b/lib/bundler/vendor/thor/lib/thor/base.rb
@@ -9,9 +9,9 @@ require "bundler/vendor/thor/lib/thor/line_editor"
require "bundler/vendor/thor/lib/thor/util"
class Bundler::Thor
- autoload :Actions, "bundler/vendor/thor/lib/thor/actions"
- autoload :RakeCompat, "bundler/vendor/thor/lib/thor/rake_compat"
- autoload :Group, "bundler/vendor/thor/lib/thor/group"
+ autoload :Actions, File.expand_path("actions", __dir__)
+ autoload :RakeCompat, File.expand_path("rake_compat", __dir__)
+ autoload :Group, File.expand_path("group", __dir__)
# Shortcuts for help.
HELP_MAPPINGS = %w(-h -? --help -D)
diff --git a/lib/bundler/vendor/thor/lib/thor/shell.rb b/lib/bundler/vendor/thor/lib/thor/shell.rb
index a68cdf8a98..e36fa472d6 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell.rb
@@ -24,9 +24,9 @@ class Bundler::Thor
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
attr_writer :shell
- autoload :Basic, "bundler/vendor/thor/lib/thor/shell/basic"
- autoload :Color, "bundler/vendor/thor/lib/thor/shell/color"
- autoload :HTML, "bundler/vendor/thor/lib/thor/shell/html"
+ autoload :Basic, File.expand_path("shell/basic", __dir__)
+ autoload :Color, File.expand_path("shell/color", __dir__)
+ autoload :HTML, File.expand_path("shell/html", __dir__)
# Add shell to initialize config values.
#
diff --git a/lib/bundler/vendored_fileutils.rb b/lib/bundler/vendored_fileutils.rb
index d14e98baf7..4b71759224 100644
--- a/lib/bundler/vendored_fileutils.rb
+++ b/lib/bundler/vendored_fileutils.rb
@@ -2,7 +2,7 @@
module Bundler; end
if RUBY_VERSION >= "2.4"
- require "bundler/vendor/fileutils/lib/fileutils"
+ require_relative "vendor/fileutils/lib/fileutils"
else
# the version we vendor is 2.4+
require "fileutils"
diff --git a/lib/bundler/vendored_molinillo.rb b/lib/bundler/vendored_molinillo.rb
index 061b634f72..d1976f5cb4 100644
--- a/lib/bundler/vendored_molinillo.rb
+++ b/lib/bundler/vendored_molinillo.rb
@@ -1,4 +1,4 @@
# frozen_string_literal: true
module Bundler; end
-require "bundler/vendor/molinillo/lib/molinillo"
+require_relative "vendor/molinillo/lib/molinillo"
diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb
index de9c42fcc1..7670b83992 100644
--- a/lib/bundler/vendored_persistent.rb
+++ b/lib/bundler/vendored_persistent.rb
@@ -15,7 +15,7 @@ module Bundler
end
end
end
-require "bundler/vendor/net-http-persistent/lib/net/http/persistent"
+require_relative "vendor/net-http-persistent/lib/net/http/persistent"
module Bundler
class PersistentHTTP < Persistent::Net::HTTP::Persistent
diff --git a/lib/bundler/vendored_thor.rb b/lib/bundler/vendored_thor.rb
index 8cca090f55..b0b7e7be84 100644
--- a/lib/bundler/vendored_thor.rb
+++ b/lib/bundler/vendored_thor.rb
@@ -5,4 +5,4 @@ module Bundler
Kernel.send(:require, "bundler/vendor/thor/lib/thor/actions")
end
end
-require "bundler/vendor/thor/lib/thor"
+require_relative "vendor/thor/lib/thor"
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index cfd6300950..21eeeb0fd4 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,23 +1,7 @@
# frozen_string_literal: false
module Bundler
- # We're doing this because we might write tests that deal
- # with other versions of bundler and we are unsure how to
- # handle this better.
- VERSION = "2.1.0.pre.1".freeze unless defined?(::Bundler::VERSION)
-
- def self.overwrite_loaded_gem_version
- begin
- require "rubygems"
- rescue LoadError
- return
- end
- return unless bundler_spec = Gem.loaded_specs["bundler"]
- return if bundler_spec.version == VERSION
- bundler_spec.version = Bundler::VERSION
- end
- private_class_method :overwrite_loaded_gem_version
- overwrite_loaded_gem_version
+ VERSION = "2.1.0.pre.1".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb
index 68181e7db8..538e8c3e74 100644
--- a/lib/bundler/vlad.rb
+++ b/lib/bundler/vlad.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "bundler/shared_helpers"
+require_relative "shared_helpers"
Bundler::SharedHelpers.major_deprecation 2,
"The Bundler task for Vlad"
@@ -8,7 +8,7 @@ Bundler::SharedHelpers.major_deprecation 2,
#
# Add "require 'bundler/vlad'" in your Vlad deploy.rb, and
# include the vlad:bundle:install task in your vlad:deploy task.
-require "bundler/deployment"
+require_relative "deployment"
include Rake::DSL if defined? Rake::DSL
diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb
index 374b3bb5e3..1965853931 100644
--- a/lib/bundler/yaml_serializer.rb
+++ b/lib/bundler/yaml_serializer.rb
@@ -3,7 +3,7 @@
module Bundler
# A stub yaml serializer that can handle only hashes and strings (as of now).
module YAMLSerializer
- module_function
+ module_function # rubocop:disable Layout/AccessModifierIndentation
def dump(hash)
yaml = String.new("---")
diff --git a/man/bundle-add.1 b/man/bundle-add.1
index e7ef637458..c2663a6ea6 100644
--- a/man/bundle-add.1
+++ b/man/bundle-add.1
@@ -1,13 +1,13 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "BUNDLE\-ADD" "1" "March 2019" "" ""
+.TH "BUNDLE\-ADD" "1" "May 2019" "" ""
.
.SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
.
.SH "SYNOPSIS"
-\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
+\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-git=GIT] [\-\-branch=BRANCH] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
.
.SH "DESCRIPTION"
Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
@@ -45,6 +45,14 @@ Specify the group(s) for the added gem\. Multiple groups should be separated by
Specify the source for the added gem\.
.
.TP
+\fB\-\-git\fR
+Specify the git source for the added gem\.
+.
+.TP
+\fB\-\-branch\fR
+Specify the git branch for the added gem\.
+.
+.TP
\fB\-\-skip\-install\fR
Adds the gem to the Gemfile but does not install it\.
.
diff --git a/man/bundle-add.1.txt b/man/bundle-add.1.txt
index 59c4b82c49..1a5223c41b 100644
--- a/man/bundle-add.1.txt
+++ b/man/bundle-add.1.txt
@@ -7,10 +7,11 @@ NAME
SYNOPSIS
bundle add GEM_NAME [--group=GROUP] [--version=VERSION]
- [--source=SOURCE] [--skip-install] [--strict] [--optimistic]
+ [--source=SOURCE] [--git=GIT] [--branch=BRANCH] [--skip-install]
+ [--strict] [--optimistic]
DESCRIPTION
- Adds the named gem to the Gemfile and run bundle install. bundle
+ Adds the named gem to the Gemfile and run bundle install. bundle
install can be avoided by using the flag --skip-install.
Example:
@@ -19,7 +20,7 @@ DESCRIPTION
bundle add rails --version "< 3.0, > 1.1"
- bundle add rails --version "~> 5.0.0" --source "https://gems.exam-
+ bundle add rails --version "~> 5.0.0" --source "https://gems.exam-
ple.com" --group "development"
bundle add rails --skip-install
@@ -31,12 +32,17 @@ OPTIONS
Specify version requirements(s) for the added gem.
--group, -g
- Specify the group(s) for the added gem. Multiple groups should
+ Specify the group(s) for the added gem. Multiple groups should
be separated by commas.
--source, , -s
Specify the source for the added gem.
+ --git Specify the git source for the added gem.
+
+ --branch
+ Specify the git branch for the added gem.
+
--skip-install
Adds the gem to the Gemfile but does not install it.
@@ -49,4 +55,4 @@ OPTIONS
- March 2019 BUNDLE-ADD(1)
+ May 2019 BUNDLE-ADD(1)
diff --git a/man/bundle-add.ronn b/man/bundle-add.ronn
index 1e2d732ec6..26cbe55647 100644
--- a/man/bundle-add.ronn
+++ b/man/bundle-add.ronn
@@ -3,7 +3,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install
## SYNOPSIS
-`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--skip-install] [--strict] [--optimistic]
+`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--git=GIT] [--branch=BRANCH] [--skip-install] [--strict] [--optimistic]
## DESCRIPTION
Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.
@@ -30,6 +30,12 @@ bundle add rails --group "development, test"
* `--source`, , `-s`:
Specify the source for the added gem.
+* `--git`:
+ Specify the git source for the added gem.
+
+* `--branch`:
+ Specify the git branch for the added gem.
+
* `--skip-install`:
Adds the gem to the Gemfile but does not install it.
diff --git a/man/bundle-config.1 b/man/bundle-config.1
index 6de75c0528..14d2ebcf97 100644
--- a/man/bundle-config.1
+++ b/man/bundle-config.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "BUNDLE\-CONFIG" "1" "April 2019" "" ""
+.TH "BUNDLE\-CONFIG" "1" "May 2019" "" ""
.
.SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options
@@ -193,9 +193,6 @@ The following is a list of all configuration keys and their purpose\. You can le
\fBdisable_version_check\fR (\fBBUNDLE_DISABLE_VERSION_CHECK\fR): Stop Bundler from checking if a newer Bundler version is available on rubygems\.org\.
.
.IP "\(bu" 4
-\fBerror_on_stderr\fR (\fBBUNDLE_ERROR_ON_STDERR\fR): Print Bundler errors to stderr\.
-.
-.IP "\(bu" 4
\fBforce_ruby_platform\fR (\fBBUNDLE_FORCE_RUBY_PLATFORM\fR): Ignore the current machine\'s platform and install only \fBruby\fR platform gems\. As a result, gems with native extensions will be compiled from source\.
.
.IP "\(bu" 4
@@ -211,9 +208,6 @@ The following is a list of all configuration keys and their purpose\. You can le
\fBglobal_gem_cache\fR (\fBBUNDLE_GLOBAL_GEM_CACHE\fR): Whether Bundler should cache all gems globally, rather than locally to the installing Ruby installation\.
.
.IP "\(bu" 4
-\fBglobal_path_appends_ruby_scope\fR (\fBBUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE\fR): Whether Bundler should append the Ruby scope (e\.g\. engine and ABI version) to a globally\-configured path\.
-.
-.IP "\(bu" 4
\fBignore_messages\fR (\fBBUNDLE_IGNORE_MESSAGES\fR): When set, no post install messages will be printed\. To silence a single gem, use dot notation like \fBignore_messages\.httparty true\fR\.
.
.IP "\(bu" 4
@@ -244,9 +238,6 @@ The following is a list of all configuration keys and their purpose\. You can le
\fBplugins\fR (\fBBUNDLE_PLUGINS\fR): Enable Bundler\'s experimental plugin system\.
.
.IP "\(bu" 4
-\fBprefer_gems_rb\fR (\fBBUNDLE_PREFER_GEMS_RB\fR) Prefer \fBgems\.rb\fR to \fBGemfile\fR when Bundler is searching for a Gemfile\.
-.
-.IP "\(bu" 4
\fBprefer_patch\fR (BUNDLE_PREFER_PATCH): Prefer updating only to next patch version during updates\. Makes \fBbundle update\fR calls equivalent to \fBbundler update \-\-patch\fR\.
.
.IP "\(bu" 4
diff --git a/man/bundle-config.1.txt b/man/bundle-config.1.txt
index 86deec54b5..a79cd311bc 100644
--- a/man/bundle-config.1.txt
+++ b/man/bundle-config.1.txt
@@ -221,37 +221,29 @@ LIST OF AVAILABLE KEYS
from checking if a newer Bundler version is available on
rubygems.org.
- o error_on_stderr (BUNDLE_ERROR_ON_STDERR): Print Bundler errors to
- stderr.
-
- o force_ruby_platform (BUNDLE_FORCE_RUBY_PLATFORM): Ignore the cur-
- rent machine's platform and install only ruby platform gems. As a
+ o force_ruby_platform (BUNDLE_FORCE_RUBY_PLATFORM): Ignore the cur-
+ rent machine's platform and install only ruby platform gems. As a
result, gems with native extensions will be compiled from source.
- o frozen (BUNDLE_FROZEN): Disallow changes to the Gemfile. When the
- Gemfile is changed and the lockfile has not been updated, running
- Bundler commands will be blocked. Defaults to true when --deploy-
+ o frozen (BUNDLE_FROZEN): Disallow changes to the Gemfile. When the
+ Gemfile is changed and the lockfile has not been updated, running
+ Bundler commands will be blocked. Defaults to true when --deploy-
ment is used.
- o gem.push_key (BUNDLE_GEM__PUSH_KEY): Sets the --key parameter for
- gem push when using the rake release command with a private gem-
+ o gem.push_key (BUNDLE_GEM__PUSH_KEY): Sets the --key parameter for
+ gem push when using the rake release command with a private gem-
stash server.
- o gemfile (BUNDLE_GEMFILE): The name of the file that bundler should
- use as the Gemfile. This location of this file also sets the root
+ o gemfile (BUNDLE_GEMFILE): The name of the file that bundler should
+ use as the Gemfile. This location of this file also sets the root
of the project, which is used to resolve relative paths in the Gem-
- file, among other things. By default, bundler will search up from
+ file, among other things. By default, bundler will search up from
the current working directory until it finds a Gemfile.
- o global_gem_cache (BUNDLE_GLOBAL_GEM_CACHE): Whether Bundler should
+ o global_gem_cache (BUNDLE_GLOBAL_GEM_CACHE): Whether Bundler should
cache all gems globally, rather than locally to the installing Ruby
installation.
- o global_path_appends_ruby_scope (BUN-
- DLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE): Whether Bundler should append
- the Ruby scope (e.g. engine and ABI version) to a globally-config-
- ured path.
-
o ignore_messages (BUNDLE_IGNORE_MESSAGES): When set, no post install
messages will be printed. To silence a single gem, use dot notation
like ignore_messages.httparty true.
@@ -287,52 +279,49 @@ LIST OF AVAILABLE KEYS
o plugins (BUNDLE_PLUGINS): Enable Bundler's experimental plugin sys-
tem.
- o prefer_gems_rb (BUNDLE_PREFER_GEMS_RB) Prefer gems.rb to Gemfile
- when Bundler is searching for a Gemfile.
-
- o prefer_patch (BUNDLE_PREFER_PATCH): Prefer updating only to next
- patch version during updates. Makes bundle update calls equivalent
+ o prefer_patch (BUNDLE_PREFER_PATCH): Prefer updating only to next
+ patch version during updates. Makes bundle update calls equivalent
to bundler update --patch.
- o print_only_version_number (BUNDLE_PRINT_ONLY_VERSION_NUMBER) Print
+ o print_only_version_number (BUNDLE_PRINT_ONLY_VERSION_NUMBER) Print
only version number from bundler --version.
- o redirect (BUNDLE_REDIRECT): The number of redirects allowed for
+ o redirect (BUNDLE_REDIRECT): The number of redirects allowed for
network requests. Defaults to 5.
- o retry (BUNDLE_RETRY): The number of times to retry failed network
+ o retry (BUNDLE_RETRY): The number of times to retry failed network
requests. Defaults to 3.
o setup_makes_kernel_gem_public (BUNDLE_SETUP_MAKES_KERNEL_GEM_PUB-
- LIC): Have Bundler.setup make the Kernel#gem method public, even
+ LIC): Have Bundler.setup make the Kernel#gem method public, even
though RubyGems declares it as private.
- o shebang (BUNDLE_SHEBANG): The program name that should be invoked
- for generated binstubs. Defaults to the ruby install name used to
+ o shebang (BUNDLE_SHEBANG): The program name that should be invoked
+ for generated binstubs. Defaults to the ruby install name used to
generate the binstub.
o silence_deprecations (BUNDLE_SILENCE_DEPRECATIONS): Whether Bundler
- should silence deprecation warnings for behavior that will be
+ should silence deprecation warnings for behavior that will be
changed in the next major version.
- o silence_root_warning (BUNDLE_SILENCE_ROOT_WARNING): Silence the
+ o silence_root_warning (BUNDLE_SILENCE_ROOT_WARNING): Silence the
warning Bundler prints when installing gems as root.
o skip_default_git_sources (BUNDLE_SKIP_DEFAULT_GIT_SOURCES): Whether
Bundler should skip adding default git source shortcuts to the Gem-
file DSL.
- o specific_platform (BUNDLE_SPECIFIC_PLATFORM): Allow bundler to
+ o specific_platform (BUNDLE_SPECIFIC_PLATFORM): Allow bundler to
resolve for the specific running platform and store it in the lock-
file, instead of only using a generic platform. A specific platform
- is the exact platform triple reported by Gem::Platform.local, such
- as x86_64-darwin-16 or universal-java-1.8. On the other hand,
- generic platforms are those such as ruby, mswin, or java. In this
- example, x86_64-darwin-16 would map to ruby and universal-java-1.8
+ is the exact platform triple reported by Gem::Platform.local, such
+ as x86_64-darwin-16 or universal-java-1.8. On the other hand,
+ generic platforms are those such as ruby, mswin, or java. In this
+ example, x86_64-darwin-16 would map to ruby and universal-java-1.8
to java.
- o ssl_ca_cert (BUNDLE_SSL_CA_CERT): Path to a designated CA certifi-
- cate file or folder containing multiple certificates for trusted
+ o ssl_ca_cert (BUNDLE_SSL_CA_CERT): Path to a designated CA certifi-
+ cate file or folder containing multiple certificates for trusted
CAs in PEM format.
o ssl_client_cert (BUNDLE_SSL_CLIENT_CERT): Path to a designated file
@@ -342,44 +331,44 @@ LIST OF AVAILABLE KEYS
Bundler uses when making HTTPS requests. Defaults to verify peer.
o suppress_install_using_messages (BUNDLE_SUPPRESS_INSTALL_USING_MES-
- SAGES): Avoid printing Using ... messages during installation when
+ SAGES): Avoid printing Using ... messages during installation when
the version of a gem has not changed.
- o system_bindir (BUNDLE_SYSTEM_BINDIR): The location where RubyGems
+ o system_bindir (BUNDLE_SYSTEM_BINDIR): The location where RubyGems
installs binstubs. Defaults to Gem.bindir.
o timeout (BUNDLE_TIMEOUT): The seconds allowed before timing out for
network requests. Defaults to 10.
o unlock_source_unlocks_spec (BUNDLE_UNLOCK_SOURCE_UNLOCKS_SPEC):
- Whether running bundle update --source NAME unlocks a gem with the
+ Whether running bundle update --source NAME unlocks a gem with the
given name. Defaults to true.
- o update_requires_all_flag (BUNDLE_UPDATE_REQUIRES_ALL_FLAG) Require
- passing --all to bundle update when everything should be updated,
+ o update_requires_all_flag (BUNDLE_UPDATE_REQUIRES_ALL_FLAG) Require
+ passing --all to bundle update when everything should be updated,
and disallow passing no options to bundle update.
- o user_agent (BUNDLE_USER_AGENT): The custom user agent fragment
+ o user_agent (BUNDLE_USER_AGENT): The custom user agent fragment
Bundler includes in API requests.
o with (BUNDLE_WITH): A :-separated list of groups whose gems bundler
should install.
- o without (BUNDLE_WITHOUT): A :-separated list of groups whose gems
+ o without (BUNDLE_WITHOUT): A :-separated list of groups whose gems
bundler should not install.
- In general, you should set these settings per-application by using the
- applicable flag to the bundle install(1) bundle-install.1.html or bun-
+ In general, you should set these settings per-application by using the
+ applicable flag to the bundle install(1) bundle-install.1.html or bun-
dle package(1) bundle-package.1.html command.
- You can set them globally either via environment variables or bundle
- config, whichever is preferable for your setup. If you use both, envi-
+ You can set them globally either via environment variables or bundle
+ config, whichever is preferable for your setup. If you use both, envi-
ronment variables will take preference over global settings.
LOCAL GIT REPOS
- Bundler also allows you to work against a git repository locally
+ Bundler also allows you to work against a git repository locally
instead of using the remote version. This can be achieved by setting up
a local override:
@@ -398,30 +387,30 @@ LOCAL GIT REPOS
- Now instead of checking out the remote git repository, the local over-
- ride will be used. Similar to a path source, every time the local git
- repository change, changes will be automatically picked up by Bundler.
- This means a commit in the local git repo will update the revision in
+ Now instead of checking out the remote git repository, the local over-
+ ride will be used. Similar to a path source, every time the local git
+ repository change, changes will be automatically picked up by Bundler.
+ This means a commit in the local git repo will update the revision in
the Gemfile.lock to the local git repo revision. This requires the same
- attention as git submodules. Before pushing to the remote, you need to
+ attention as git submodules. Before pushing to the remote, you need to
ensure the local override was pushed, otherwise you may point to a com-
- mit that only exists in your local machine. You'll also need to CGI
+ mit that only exists in your local machine. You'll also need to CGI
escape your usernames and passwords as well.
- Bundler does many checks to ensure a developer won't work with invalid
- references. Particularly, we force a developer to specify a branch in
- the Gemfile in order to use this feature. If the branch specified in
- the Gemfile and the current branch in the local git repository do not
- match, Bundler will abort. This ensures that a developer is always
- working against the correct branches, and prevents accidental locking
+ Bundler does many checks to ensure a developer won't work with invalid
+ references. Particularly, we force a developer to specify a branch in
+ the Gemfile in order to use this feature. If the branch specified in
+ the Gemfile and the current branch in the local git repository do not
+ match, Bundler will abort. This ensures that a developer is always
+ working against the correct branches, and prevents accidental locking
to a different branch.
- Finally, Bundler also ensures that the current revision in the Gem-
- file.lock exists in the local git repository. By doing this, Bundler
+ Finally, Bundler also ensures that the current revision in the Gem-
+ file.lock exists in the local git repository. By doing this, Bundler
forces you to fetch the latest changes in the remotes.
MIRRORS OF GEM SOURCES
- Bundler supports overriding gem sources with mirrors. This allows you
+ Bundler supports overriding gem sources with mirrors. This allows you
to configure rubygems.org as the gem source in your Gemfile while still
using your mirror to fetch gems.
@@ -431,7 +420,7 @@ MIRRORS OF GEM SOURCES
- For example, to use a mirror of rubygems.org hosted at rubygems-mir-
+ For example, to use a mirror of rubygems.org hosted at rubygems-mir-
ror.org:
@@ -440,8 +429,8 @@ MIRRORS OF GEM SOURCES
- Each mirror also provides a fallback timeout setting. If the mirror
- does not respond within the fallback timeout, Bundler will try to use
+ Each mirror also provides a fallback timeout setting. If the mirror
+ does not respond within the fallback timeout, Bundler will try to use
the original server instead of the mirror.
@@ -458,11 +447,11 @@ MIRRORS OF GEM SOURCES
- The default fallback timeout is 0.1 seconds, but the setting can cur-
+ The default fallback timeout is 0.1 seconds, but the setting can cur-
rently only accept whole seconds (for example, 1, 15, or 30).
CREDENTIALS FOR GEM SOURCES
- Bundler allows you to configure credentials for any gem source, which
+ Bundler allows you to configure credentials for any gem source, which
allows you to avoid putting secrets into your Gemfile.
@@ -471,7 +460,7 @@ CREDENTIALS FOR GEM SOURCES
- For example, to save the credentials of user claudette for the gem
+ For example, to save the credentials of user claudette for the gem
source at gems.longerous.com, you would run:
@@ -505,7 +494,7 @@ CREDENTIALS FOR GEM SOURCES
- This is especially useful for private repositories on hosts such as
+ This is especially useful for private repositories on hosts such as
Github, where you can use personal OAuth tokens:
@@ -515,9 +504,9 @@ CREDENTIALS FOR GEM SOURCES
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 ~/.bundle, which all directories inherit
+ 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 ~/.bundle, which all directories inherit
from by default. The following outlines the available environment vari-
ables and their default values
@@ -533,4 +522,4 @@ CONFIGURE BUNDLER DIRECTORIES
- April 2019 BUNDLE-CONFIG(1)
+ May 2019 BUNDLE-CONFIG(1)
diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn
index 86c4e21819..7d3b8dcc8d 100644
--- a/man/bundle-config.ronn
+++ b/man/bundle-config.ronn
@@ -183,8 +183,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `disable_version_check` (`BUNDLE_DISABLE_VERSION_CHECK`):
Stop Bundler from checking if a newer Bundler version is available on
rubygems.org.
-* `error_on_stderr` (`BUNDLE_ERROR_ON_STDERR`):
- Print Bundler errors to stderr.
* `force_ruby_platform` (`BUNDLE_FORCE_RUBY_PLATFORM`):
Ignore the current machine's platform and install only `ruby` platform gems.
As a result, gems with native extensions will be compiled from source.
@@ -204,9 +202,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `global_gem_cache` (`BUNDLE_GLOBAL_GEM_CACHE`):
Whether Bundler should cache all gems globally, rather than locally to the
installing Ruby installation.
-* `global_path_appends_ruby_scope` (`BUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE`):
- Whether Bundler should append the Ruby scope (e.g. engine and ABI version)
- to a globally-configured path.
* `ignore_messages` (`BUNDLE_IGNORE_MESSAGES`): When set, no post install
messages will be printed. To silence a single gem, use dot notation like
`ignore_messages.httparty true`.
diff --git a/man/bundle.1 b/man/bundle.1
index 81226d9339..fd6343c793 100644
--- a/man/bundle.1
+++ b/man/bundle.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "BUNDLE" "1" "April 2019" "" ""
+.TH "BUNDLE" "1" "May 2019" "" ""
.
.SH "NAME"
\fBbundle\fR \- Ruby Dependency Management
@@ -89,7 +89,7 @@ Start an IRB session in the current bundle
Open an installed gem in the editor
.
.TP
-\fBbundle lock(1)\fR \fIbundle\-lock\.1\.hmtl\fR
+\fBbundle lock(1)\fR \fIbundle\-lock\.1\.html\fR
Generate a lockfile for your dependencies
.
.TP
diff --git a/man/bundle.1.txt b/man/bundle.1.txt
index bbf869d4c5..f5c3d8ae7f 100644
--- a/man/bundle.1.txt
+++ b/man/bundle.1.txt
@@ -71,7 +71,7 @@ UTILITIES
bundle open(1) bundle-open.1.html
Open an installed gem in the editor
- bundle lock(1) bundle-lock.1.hmtl
+ bundle lock(1) bundle-lock.1.html
Generate a lockfile for your dependencies
bundle viz(1) bundle-viz.1.html
@@ -113,4 +113,4 @@ OBSOLETE
- April 2019 BUNDLE(1)
+ May 2019 BUNDLE(1)
diff --git a/man/bundle.ronn b/man/bundle.ronn
index b8ee4566b4..5b1712394a 100644
--- a/man/bundle.ronn
+++ b/man/bundle.ronn
@@ -73,7 +73,7 @@ We divide `bundle` subcommands into primary commands and utilities:
* [`bundle open(1)`](bundle-open.1.html):
Open an installed gem in the editor
-* [`bundle lock(1)`](bundle-lock.1.hmtl):
+* [`bundle lock(1)`](bundle-lock.1.html):
Generate a lockfile for your dependencies
* [`bundle viz(1)`](bundle-viz.1.html):
diff --git a/spec/bundler/bundler/bundler_spec.rb b/spec/bundler/bundler/bundler_spec.rb
index e33c8dc606..f74c1780bd 100644
--- a/spec/bundler/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler/bundler_spec.rb
@@ -370,54 +370,51 @@ EOF
it { should be true }
end
end
- end
- describe "#requires_sudo?" do
- before do
- allow(Bundler).to receive(:which).with("sudo").and_return("/usr/bin/sudo")
- FileUtils.mkdir_p("tmp/vendor/bundle")
- FileUtils.mkdir_p("tmp/vendor/bin_dir")
- end
- after do
- FileUtils.rm_rf("tmp/vendor/bundle")
- FileUtils.rm_rf("tmp/vendor/bin_dir")
- Bundler.remove_instance_variable(:@requires_sudo_ran)
- Bundler.remove_instance_variable(:@requires_sudo)
- end
- context "writable paths" do
- it "should return false and display nothing" do
- allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
- expect(Bundler.ui).to_not receive(:warn)
- expect(Bundler.requires_sudo?).to eq(false)
- end
- end
- context "unwritable paths" do
+ context "path writability" do
before do
- FileUtils.touch("tmp/vendor/bundle/unwritable1.txt")
- FileUtils.touch("tmp/vendor/bundle/unwritable2.txt")
- FileUtils.touch("tmp/vendor/bin_dir/unwritable3.txt")
- FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable1.txt")
- FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable2.txt")
- FileUtils.chmod(0o400, "tmp/vendor/bin_dir/unwritable3.txt")
+ FileUtils.mkdir_p("tmp/vendor/bundle")
+ FileUtils.mkdir_p("tmp/vendor/bin_dir")
+ end
+ after do
+ FileUtils.rm_rf("tmp/vendor/bundle")
+ FileUtils.rm_rf("tmp/vendor/bin_dir")
end
- it "should return true and display warn message" do
- allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
- bin_dir = Pathname("tmp/vendor/bin_dir/")
+ context "writable paths" do
+ it "should return false and display nothing" do
+ allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
+ expect(Bundler.ui).to_not receive(:warn)
+ expect(Bundler.requires_sudo?).to eq(false)
+ end
+ end
+ context "unwritable paths" do
+ before do
+ FileUtils.touch("tmp/vendor/bundle/unwritable1.txt")
+ FileUtils.touch("tmp/vendor/bundle/unwritable2.txt")
+ FileUtils.touch("tmp/vendor/bin_dir/unwritable3.txt")
+ FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable1.txt")
+ FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable2.txt")
+ FileUtils.chmod(0o400, "tmp/vendor/bin_dir/unwritable3.txt")
+ end
+ it "should return true and display warn message" do
+ allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
+ bin_dir = Pathname("tmp/vendor/bin_dir/")
- # allow File#writable? to be called with args other than the stubbed on below
- allow(File).to receive(:writable?).and_call_original
+ # allow File#writable? to be called with args other than the stubbed on below
+ allow(File).to receive(:writable?).and_call_original
- # fake make the directory unwritable
- allow(File).to receive(:writable?).with(bin_dir).and_return(false)
- allow(Bundler).to receive(:system_bindir).and_return(Pathname("tmp/vendor/bin_dir/"))
- message = <<-MESSAGE.chomp
+ # fake make the directory unwritable
+ allow(File).to receive(:writable?).with(bin_dir).and_return(false)
+ allow(Bundler).to receive(:system_bindir).and_return(Pathname("tmp/vendor/bin_dir/"))
+ message = <<-MESSAGE.chomp
Following files may not be writable, so sudo is needed:
tmp/vendor/bin_dir/
tmp/vendor/bundle/unwritable1.txt
tmp/vendor/bundle/unwritable2.txt
MESSAGE
- expect(Bundler.ui).to receive(:warn).with(message)
- expect(Bundler.requires_sudo?).to eq(true)
+ expect(Bundler.ui).to receive(:warn).with(message)
+ expect(Bundler.requires_sudo?).to eq(true)
+ end
end
end
end
@@ -457,6 +454,7 @@ MESSAGE
it "should use custom home path as root for other paths" do
ENV["BUNDLE_USER_HOME"] = bundle_user_home_custom.to_s
+ allow(Bundler.rubygems).to receive(:user_home).and_raise
expect(Bundler.user_bundle_path).to eq(bundle_user_home_custom)
expect(Bundler.user_bundle_path("home")).to eq(bundle_user_home_custom)
expect(Bundler.user_bundle_path("cache")).to eq(bundle_user_home_custom.join("cache"))
diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb
index 6a505358d1..2e12fbfc6b 100644
--- a/spec/bundler/bundler/cli_spec.rb
+++ b/spec/bundler/bundler/cli_spec.rb
@@ -30,8 +30,8 @@ RSpec.describe "bundle executable" do
context "with no arguments" do
it "prints a concise help message", :bundler => "3" do
bundle! ""
- expect(last_command.stderr).to be_empty
- expect(last_command.stdout).to include("Bundler version #{Bundler::VERSION}").
+ expect(err).to be_empty
+ expect(out).to include("Bundler version #{Bundler::VERSION}").
and include("\n\nBundler commands:\n\n").
and include("\n\n Primary commands:\n").
and include("\n\n Utilities:\n").
@@ -72,17 +72,17 @@ RSpec.describe "bundle executable" do
it "prints the running command" do
gemfile ""
bundle! "info bundler", :verbose => true
- expect(last_command.stdout).to start_with("Running `bundle info bundler --verbose` with bundler #{Bundler::VERSION}")
+ expect(out).to start_with("Running `bundle info bundler --verbose` with bundler #{Bundler::VERSION}")
end
it "doesn't print defaults" do
install_gemfile! "", :verbose => true
- expect(last_command.stdout).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
+ expect(out).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
end
it "doesn't print defaults" do
install_gemfile! "", :verbose => true
- expect(last_command.stdout).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
+ expect(out).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
end
end
@@ -125,7 +125,7 @@ RSpec.describe "bundle executable" do
let(:latest_version) { "222.0" }
it "prints the version warning" do
bundle "fail"
- expect(last_command.stdout).to start_with(<<-EOS.strip)
+ expect(err).to start_with(<<-EOS.strip)
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler`
EOS
@@ -150,7 +150,7 @@ To install the latest version, run `gem install bundler`
let(:latest_version) { "222.0.0.pre.4" }
it "prints the version warning" do
bundle "fail"
- expect(last_command.stdout).to start_with(<<-EOS.strip)
+ expect(err).to start_with(<<-EOS.strip)
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler --pre`
EOS
diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb
index de2a43adc6..214d159d05 100644
--- a/spec/bundler/bundler/dsl_spec.rb
+++ b/spec/bundler/bundler/dsl_spec.rb
@@ -25,60 +25,17 @@ RSpec.describe Bundler::Dsl do
expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption)
end
- context "github_https feature flag" do
- it "is true when github.https is true" do
- bundle "config set github.https true"
- expect(Bundler.feature_flag.github_https?).to eq true
- end
- end
-
- shared_examples_for "the github DSL" do |protocol|
- context "when full repo is used" do
- let(:repo) { "indirect/sparks" }
-
- it "converts :github to URI using #{protocol}" do
- subject.gem("sparks", :github => repo)
- github_uri = "#{protocol}://github.com/#{repo}.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
- end
-
- context "when shortcut repo is used" do
- let(:repo) { "rails" }
-
- it "converts :github to URI using #{protocol}" do
- subject.gem("sparks", :github => repo)
- github_uri = "#{protocol}://github.com/#{repo}/#{repo}.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
- end
- end
-
- context "default hosts (git, gist)" do
- context "when github.https config is true" do
- before { bundle "config set github.https true" }
-
- it_behaves_like "the github DSL", "https"
- end
-
- context "when github.https config is false", :bundler => "2" do
- before { bundle "config set github.https false" }
-
- it_behaves_like "the github DSL", "git"
- end
-
- context "when github.https config is false", :bundler => "3" do
- before { bundle "config set github.https false" }
-
- pending "should show a proper message about the removed setting"
- end
-
- context "by default", :bundler => "2" do
- it_behaves_like "the github DSL", "https"
+ context "default hosts", :bundler => "2" do
+ it "converts :github to URI using https" do
+ subject.gem("sparks", :github => "indirect/sparks")
+ github_uri = "https://github.com/indirect/sparks.git"
+ expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
- context "by default", :bundler => "3" do
- it_behaves_like "the github DSL", "https"
+ it "converts :github shortcut to URI using https" do
+ subject.gem("sparks", :github => "rails")
+ github_uri = "https://github.com/rails/rails.git"
+ expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
it "converts numeric :gist to :git" do
@@ -106,7 +63,7 @@ RSpec.describe Bundler::Dsl do
end
end
- context "default git sources", :bundler => "4" do
+ context "default git sources", :bundler => "3" do
it "has none" do
expect(subject.instance_variable_get(:@git_sources)).to eq({})
end
@@ -285,7 +242,7 @@ RSpec.describe Bundler::Dsl do
end
end
- describe "#github", :bundler => "3" do
+ describe "#github", :bundler => "2" do
it "from github" do
spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do
@@ -300,19 +257,6 @@ RSpec.describe Bundler::Dsl do
describe "#github", :bundler => "3" do
it "from github" do
- spree_gems = %w[spree_core spree_api spree_backend]
- subject.github "spree" do
- spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
- end
-
- subject.dependencies.each do |d|
- expect(d.source.uri).to eq("https://github.com/spree/spree.git")
- end
- end
- end
-
- describe "#github", :bundler => "4" do
- it "from github" do
expect do
spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do
diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb
index 20bd38b021..8323a9a7b3 100644
--- a/spec/bundler/bundler/env_spec.rb
+++ b/spec/bundler/bundler/env_spec.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
+require "openssl"
require "bundler/settings"
RSpec.describe Bundler::Env do
@@ -17,6 +18,54 @@ RSpec.describe Bundler::Env do
expect(out).to include(OpenSSL::OPENSSL_VERSION)
end
+ describe "rubygems paths" do
+ it "prints gem home" do
+ with_clear_paths("GEM_HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("Gem Home /a/b/c")
+ end
+ end
+
+ it "prints gem path" do
+ with_clear_paths("GEM_PATH", "/a/b/c:/d/e/f") do
+ out = described_class.report
+ expect(out).to include("Gem Path /a/b/c:/d/e/f")
+ end
+ end
+
+ it "prints user home" do
+ with_clear_paths("HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("User Home /a/b/c")
+ end
+ end
+
+ it "prints user path" do
+ with_clear_paths("HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("User Path /a/b/c/.gem")
+ end
+ end
+
+ it "prints bin dir" do
+ with_clear_paths("GEM_HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("Bin Dir /a/b/c/bin")
+ end
+ end
+
+ private
+
+ def with_clear_paths(env_var, env_value)
+ old_env_var = ENV[env_var]
+ ENV[env_var] = env_value
+ Gem.clear_paths
+ yield
+ ensure
+ ENV[env_var] = old_env_var
+ end
+ end
+
context "when there is a Gemfile and a lockfile and print_gemfile is true" do
before do
gemfile "gem 'rack', '1.0.0'"
diff --git a/spec/bundler/bundler/fetcher/compact_index_spec.rb b/spec/bundler/bundler/fetcher/compact_index_spec.rb
index 5a2d22193a..2f622f6653 100644
--- a/spec/bundler/bundler/fetcher/compact_index_spec.rb
+++ b/spec/bundler/bundler/fetcher/compact_index_spec.rb
@@ -11,11 +11,14 @@ RSpec.describe Bundler::Fetcher::CompactIndex do
end
describe "#specs_for_names" do
+ let(:thread_list) { Thread.list.select {|thread| thread.status == "run" } }
+ let(:thread_inspection) { thread_list.map {|th| " * #{th}:\n #{th.backtrace_locations.join("\n ")}" }.join("\n") }
+
it "has only one thread open at the end of the run" do
compact_index.specs_for_names(["lskdjf"])
- thread_count = Thread.list.count {|thread| thread.status == "run" }
- expect(thread_count).to eq 1
+ thread_count = thread_list.count
+ expect(thread_count).to eq(1), "Expected 1 active thread after `#specs_for_names`, but found #{thread_count}. In particular, found:\n#{thread_inspection}"
end
it "calls worker#stop during the run" do
diff --git a/spec/bundler/bundler/fetcher/downloader_spec.rb b/spec/bundler/bundler/fetcher/downloader_spec.rb
index 07b507266b..f985b88982 100644
--- a/spec/bundler/bundler/fetcher/downloader_spec.rb
+++ b/spec/bundler/bundler/fetcher/downloader_spec.rb
@@ -82,6 +82,15 @@ RSpec.describe Bundler::Fetcher::Downloader do
expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
/Authentication is required for www.uri-to-fetch.com/)
end
+
+ context "when the there are credentials provided in the request" do
+ let(:uri) { URI("http://user:password@www.uri-to-fetch.com") }
+
+ it "should raise a Bundler::Fetcher::BadAuthenticationError that doesn't contain the password" do
+ expect { subject.fetch(uri, options, counter) }.
+ to raise_error(Bundler::Fetcher::BadAuthenticationError, /Bad username or password for www.uri-to-fetch.com/)
+ end
+ end
end
context "when the request response is a Net::HTTPNotFound" do
diff --git a/spec/bundler/bundler/fetcher/index_spec.rb b/spec/bundler/bundler/fetcher/index_spec.rb
index 0cf0ae764e..d5ededae3e 100644
--- a/spec/bundler/bundler/fetcher/index_spec.rb
+++ b/spec/bundler/bundler/fetcher/index_spec.rb
@@ -35,9 +35,26 @@ RSpec.describe Bundler::Fetcher::Index do
context "when a 401 response occurs" do
let(:error_message) { "401" }
- it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
- %r{Authentication is required for http://remote-uri.org})
+ before do
+ allow(remote_uri).to receive(:userinfo).and_return(userinfo)
+ end
+
+ context "and there was userinfo" do
+ let(:userinfo) { double(:userinfo) }
+
+ it "should raise a Bundler::Fetcher::BadAuthenticationError" do
+ expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::BadAuthenticationError,
+ %r{Bad username or password for http://remote-uri.org})
+ end
+ end
+
+ context "and there was no userinfo" do
+ let(:userinfo) { nil }
+
+ it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do
+ expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
+ %r{Authentication is required for http://remote-uri.org})
+ end
end
end
diff --git a/spec/bundler/bundler/friendly_errors_spec.rb b/spec/bundler/bundler/friendly_errors_spec.rb
index 4ca1e543c1..07ec196b86 100644
--- a/spec/bundler/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/bundler/friendly_errors_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Bundler, "friendly errors" do
bundle :install, :env => { "DEBUG" => true }
- expect(last_command.stderr).to include("Failed to load #{home(".gemrc")}")
+ expect(err).to include("Failed to load #{home(".gemrc")}")
expect(exitstatus).to eq(0) if exitstatus
end
end
diff --git a/spec/bundler/bundler/plugin/events_spec.rb b/spec/bundler/bundler/plugin/events_spec.rb
index b09e915682..28d70c6fdd 100644
--- a/spec/bundler/bundler/plugin/events_spec.rb
+++ b/spec/bundler/bundler/plugin/events_spec.rb
@@ -2,10 +2,14 @@
RSpec.describe Bundler::Plugin::Events do
context "plugin events" do
+ before { Bundler::Plugin::Events.send :reset }
+
describe "#define" do
it "raises when redefining a constant" do
+ Bundler::Plugin::Events.send(:define, :TEST_EVENT, "foo")
+
expect do
- Bundler::Plugin::Events.send(:define, :GEM_BEFORE_INSTALL_ALL, "another-value")
+ Bundler::Plugin::Events.send(:define, :TEST_EVENT, "bar")
end.to raise_error(ArgumentError)
end
diff --git a/spec/bundler/bundler/ruby_version_spec.rb b/spec/bundler/bundler/ruby_version_spec.rb
index 46a1b2918b..3ac7d9ef3a 100644
--- a/spec/bundler/bundler/ruby_version_spec.rb
+++ b/spec/bundler/bundler/ruby_version_spec.rb
@@ -399,8 +399,14 @@ RSpec.describe "Bundler::RubyVersion and its subclasses" do
let(:bundler_system_ruby_version) { subject }
- before do
- Bundler::RubyVersion.instance_variable_set("@ruby_version", nil)
+ around do |example|
+ begin
+ old_ruby_version = Bundler::RubyVersion.instance_variable_get("@ruby_version")
+ Bundler::RubyVersion.instance_variable_set("@ruby_version", nil)
+ example.run
+ ensure
+ Bundler::RubyVersion.instance_variable_set("@ruby_version", old_ruby_version)
+ end
end
it "should return an instance of Bundler::RubyVersion" do
diff --git a/spec/bundler/bundler/shared_helpers_spec.rb b/spec/bundler/bundler/shared_helpers_spec.rb
index f42d9ed485..8e82d1b910 100644
--- a/spec/bundler/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/bundler/shared_helpers_spec.rb
@@ -236,7 +236,7 @@ RSpec.describe Bundler::SharedHelpers do
shared_examples_for "ENV['RUBYOPT'] gets set correctly" do
it "ensures -rbundler/setup is at the beginning of ENV['RUBYOPT']" do
subject.set_bundle_environment
- expect(ENV["RUBYOPT"].split(" ")).to start_with("-rbundler/setup")
+ expect(ENV["RUBYOPT"].split(" ")).to start_with("-r#{File.expand_path("../../lib/bundler/setup", __dir__)}")
end
end
diff --git a/spec/bundler/bundler/ui/shell_spec.rb b/spec/bundler/bundler/ui/shell_spec.rb
index 23a7670dd1..632477096e 100644
--- a/spec/bundler/bundler/ui/shell_spec.rb
+++ b/spec/bundler/bundler/ui/shell_spec.rb
@@ -24,13 +24,6 @@ RSpec.describe Bundler::UI::Shell do
it "prints to stderr" do
expect { subject.warn("warning") }.to output("warning\n").to_stderr
end
-
- context "when stderr flag is enabled" do
- before { Bundler.settings.temporary(:error_on_stderr => true) }
- it "prints to stderr" do
- expect { subject.warn("warning!") }.to output("warning!\n").to_stderr
- end
- end
end
describe "#debug" do
@@ -46,19 +39,12 @@ RSpec.describe Bundler::UI::Shell do
expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
end
- context "when stderr flag is enabled" do
- before { Bundler.settings.temporary(:error_on_stderr => true) }
- it "prints to stderr" do
- expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
- end
-
- context "when stderr is closed" do
- it "doesn't report anything" do
- output = capture(:stderr, :closed => true) do
- subject.error("Something went wrong")
- end
- expect(output).to_not eq("Something went wrong\n")
+ context "when stderr is closed" do
+ it "doesn't report anything" do
+ output = capture(:stderr, :closed => true) do
+ subject.error("Something went wrong")
end
+ expect(output).to_not eq("Something went wrong\n")
end
end
end
diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb
index 55a24ff118..d31d607d25 100644
--- a/spec/bundler/cache/git_spec.rb
+++ b/spec/bundler/cache/git_spec.rb
@@ -59,7 +59,7 @@ end
bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
- expect(last_command.stdout).to include "Updating files in vendor/cache"
+ expect(out).to include "Updating files in vendor/cache"
FileUtils.rm_rf lib_path("foo-1.0")
expect(the_bundle).to include_gems "foo 1.0"
end
diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb
index dac1d0f6b9..f5b3f49bb1 100644
--- a/spec/bundler/commands/add_spec.rb
+++ b/spec/bundler/commands/add_spec.rb
@@ -11,6 +11,8 @@ RSpec.describe "bundle add" do
build_gem "dog", "1.1.3.pre"
end
+ build_git "foo", "2.0"
+
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "weakling", "~> 0.0.1"
@@ -21,7 +23,7 @@ RSpec.describe "bundle add" do
it "shows error" do
bundle "add"
- expect(last_command.bundler_err).to include("Please specify gems to add")
+ expect(err).to include("Please specify gems to add")
end
end
@@ -89,6 +91,28 @@ RSpec.describe "bundle add" do
end
end
+ describe "with --git" do
+ it "adds dependency with specified github source" do
+ bundle "add foo --git=#{lib_path("foo-2.0")}"
+
+ expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/)
+ expect(the_bundle).to include_gems "foo 2.0"
+ end
+ end
+
+ describe "with --git and --branch" do
+ before do
+ update_git "foo", "2.0", :branch => "test"
+ end
+
+ it "adds dependency with specified github source and branch" do
+ bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test"
+
+ expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/)
+ expect(the_bundle).to include_gems "foo 2.0"
+ end
+ end
+
describe "with --skip-install" do
it "adds gem to Gemfile but is not installed" do
bundle "add foo --skip-install --version=2.0"
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb
index 92fa6812b0..4f310784c7 100644
--- a/spec/bundler/commands/binstubs_spec.rb
+++ b/spec/bundler/commands/binstubs_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe "bundle binstubs <gem>" do
bundle "binstubs rack", :all => true
expect(last_command).to be_failure
- expect(last_command.bundler_err).to include("Cannot specify --all with specific gems")
+ expect(err).to include("Cannot specify --all with specific gems")
end
context "when generating bundle binstub outside bundler" do
@@ -88,7 +88,7 @@ RSpec.describe "bundle binstubs <gem>" do
sys_exec "bin/rackup"
- expect(last_command.stderr).to include("was not generated by Bundler")
+ expect(err).to include("was not generated by Bundler")
end
end
@@ -135,7 +135,7 @@ RSpec.describe "bundle binstubs <gem>" do
it "runs the correct version of bundler" do
sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
end
@@ -145,7 +145,7 @@ RSpec.describe "bundle binstubs <gem>" do
lockfile lockfile.gsub(system_bundler_version, "999.999.999")
sys_exec "#{bundled_app("bin/bundle")} install"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
@@ -154,7 +154,7 @@ RSpec.describe "bundle binstubs <gem>" do
lockfile lockfile.gsub(system_bundler_version, "44.0")
sys_exec "#{bundled_app("bin/bundle")} install"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (44.0) failed:").
+ expect(err).to include("Activating bundler (44.0) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '44.0'`")
end
@@ -163,7 +163,7 @@ RSpec.describe "bundle binstubs <gem>" do
lockfile lockfile.gsub(system_bundler_version, "2.12.0.a")
sys_exec "#{bundled_app("bin/bundle")} install"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (2.12.0.a) failed:").
+ expect(err).to include("Activating bundler (2.12.0.a) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '2.12.0.a'`")
end
end
@@ -173,13 +173,13 @@ RSpec.describe "bundle binstubs <gem>" do
it "calls through to the latest bundler version" do
sys_exec! "#{bundled_app("bin/bundle")} update --bundler"
- expect(last_command.stdout).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"])
+ expect(out).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"])
end
it "calls through to the explicit bundler version" do
sys_exec "#{bundled_app("bin/bundle")} update --bundler=999.999.999"
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
end
@@ -205,7 +205,7 @@ RSpec.describe "bundle binstubs <gem>" do
it "attempts to load that version" do
sys_exec bundled_app("bin/rackup").to_s
expect(exitstatus).to eq(42) if exitstatus
- expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
+ expect(err).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
end
end
diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb
index 7114610644..cf88736612 100644
--- a/spec/bundler/commands/check_spec.rb
+++ b/spec/bundler/commands/check_spec.rb
@@ -338,7 +338,7 @@ RSpec.describe "bundle check" do
it "does not change the lock but warns" do
lockfile lock_with(Bundler::VERSION.succ)
bundle! :check
- expect(last_command.bundler_err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})")
+ expect(err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})")
lockfile_should_be lock_with(Bundler::VERSION.succ)
end
end
diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb
index 976916a9fe..40fab95803 100644
--- a/spec/bundler/commands/config_spec.rb
+++ b/spec/bundler/commands/config_spec.rb
@@ -391,86 +391,86 @@ E
describe "subcommands" do
it "list", :ruby_repo do
bundle! "config list"
- expect(last_command.stdout).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
+ expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
bundle! "config list", :parseable => true
- expect(last_command.stdout).to eq "spec_run=true"
+ expect(out).to eq "spec_run=true"
end
it "get" do
ENV["BUNDLE_BAR"] = "bar_val"
bundle! "config get foo"
- expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
+ expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
ENV["BUNDLE_FOO"] = "foo_val"
bundle! "config get foo --parseable"
- expect(last_command.stdout).to eq "foo=foo_val"
+ expect(out).to eq "foo=foo_val"
bundle! "config get foo"
- expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
+ expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
end
it "set" do
bundle! "config set foo 1"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --local foo 2"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --global foo 3"
- expect(last_command.stdout).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
+ expect(out).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
bundle! "config set --parseable --local foo 4"
- expect(last_command.stdout).to eq "foo=4"
+ expect(out).to eq "foo=4"
bundle! "config set --local foo 4.1"
- expect(last_command.stdout).to eq "You are replacing the current local value of foo, which is currently \"4\""
+ expect(out).to eq "You are replacing the current local value of foo, which is currently \"4\""
bundle "config set --global --local foo 5"
expect(last_command).to be_failure
- expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
end
it "unset" do
bundle! "config unset foo"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set foo 1"
bundle! "config unset foo --parseable"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo --local"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\""
bundle! "config unset foo --global"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo --global"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\""
bundle! "config unset foo --local"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle "config unset foo --local --global"
expect(last_command).to be_failure
- expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
end
end
end
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index 66096a91a1..8f49c576b5 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -55,6 +55,17 @@ RSpec.describe "bundle exec" do
expect(out).to eq("hi")
end
+ it "respects custom process title when loading through ruby" do
+ script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~RUBY
+ Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16")
+ puts `ps -eo args | grep [1]-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16`
+ RUBY
+ create_file "Gemfile"
+ create_file "a.rb", script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility
+ bundle "exec ruby a.rb"
+ expect(out).to eq("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16")
+ end
+
it "accepts --verbose" do
install_gemfile 'gem "rack"'
bundle "exec --verbose echo foobar"
@@ -88,14 +99,14 @@ RSpec.describe "bundle exec" do
sys_exec "#{Gem.ruby} #{command.path}"
expect(out).to eq("")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "accepts --keep-file-descriptors" do
install_gemfile ""
bundle "exec --keep-file-descriptors echo foobar"
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "can run a command named --verbose" do
@@ -156,7 +167,7 @@ RSpec.describe "bundle exec" do
bundle! "exec irb --version"
expect(out).to include(default_irb_version)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -182,7 +193,7 @@ RSpec.describe "bundle exec" do
bundle! "exec irb --version"
expect(out).to include(specified_irb_version)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -212,7 +223,7 @@ RSpec.describe "bundle exec" do
it "uses resolved version" do
expect(out).to include(indirect_irb_version)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
end
@@ -268,7 +279,7 @@ RSpec.describe "bundle exec" do
G
rubyopt = ENV["RUBYOPT"]
- rubyopt = "-rbundler/setup #{rubyopt}"
+ rubyopt = "-r#{File.expand_path("../../lib/bundler/setup", __dir__)} #{rubyopt}"
bundle "exec 'echo $RUBYOPT'"
expect(out).to have_rubyopts(rubyopt)
@@ -334,7 +345,7 @@ RSpec.describe "bundle exec" do
[true, false].each do |l|
bundle! "config set disable_exec_load #{l}"
bundle "exec rackup"
- expect(last_command.stderr).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
+ expect(err).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
end
end
@@ -552,8 +563,8 @@ RSpec.describe "bundle exec" do
bundle "exec irb"
- expect(last_command.stderr).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
- expect(last_command.stderr).to match('"TODO" is not a summary')
+ expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
+ expect(err).to match('"TODO" is not a summary')
end
end
@@ -614,8 +625,8 @@ RSpec.describe "bundle exec" do
it "like a normally executed executable" do
subject
expect(exitstatus).to eq(exit_code) if exitstatus
- expect(last_command.stderr).to eq(expected_err)
- expect(last_command.stdout).to eq(expected)
+ expect(err).to eq(expected_err)
+ expect(out).to eq(expected)
end
end
@@ -886,7 +897,7 @@ __FILE__: #{path.to_s.inspect}
# sanity check that we get the newer, custom version without bundler
sys_exec("#{Gem.ruby} #{file}")
- expect(last_command.stderr).to include("custom openssl should not be loaded")
+ expect(err).to include("custom openssl should not be loaded")
end
end
end
diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb
index 64849beeb9..7960ce85bd 100644
--- a/spec/bundler/commands/init_spec.rb
+++ b/spec/bundler/commands/init_spec.rb
@@ -94,7 +94,7 @@ RSpec.describe "bundle init" do
end
bundle :init, :gemspec => spec_file
- expect(last_command.bundler_err).to include("There was an error while loading `test.gemspec`")
+ expect(err).to include("There was an error while loading `test.gemspec`")
end
end
end
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index 21157dd309..1a027a77c9 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe "bundle install with gem sources" do
raise StandardError, "FAIL"
G
- expect(last_command.bundler_err).to include('StandardError, "FAIL"')
+ expect(err).to include('StandardError, "FAIL"')
expect(bundled_app("Gemfile.lock")).not_to exist
end
@@ -404,7 +404,7 @@ RSpec.describe "bundle install with gem sources" do
G
expect(last_command.stdboth).not_to match(/Error Report/i)
- expect(last_command.bundler_err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
+ expect(err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
and include(normalize_uri_file("Make sure that `gem install ajp-rails -v '0.0.0' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling."))
end
diff --git a/spec/bundler/commands/licenses_spec.rb b/spec/bundler/commands/licenses_spec.rb
index 21fd8eaf2f..423921e282 100644
--- a/spec/bundler/commands/licenses_spec.rb
+++ b/spec/bundler/commands/licenses_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe "bundle licenses" do
it "prints license information for all gems in the bundle" do
bundle "licenses"
- expect(err).to include("bundler: Unknown")
+ expect(out).to include("bundler: MIT")
expect(out).to include("with_license: MIT")
end
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
index f876d719cc..7aaf5c178e 100644
--- a/spec/bundler/commands/lock_spec.rb
+++ b/spec/bundler/commands/lock_spec.rb
@@ -242,7 +242,7 @@ RSpec.describe "bundle lock" do
it "errors when removing all platforms" do
bundle "lock --remove-platform #{local_platforms.join(" ")}"
- expect(last_command.bundler_err).to include("Removing all platforms from the bundle is not allowed")
+ expect(err).to include("Removing all platforms from the bundle is not allowed")
end
# from https://github.com/bundler/bundler/issues/4896
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 528ebf7c2b..203b474877 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -1,11 +1,6 @@
# frozen_string_literal: true
RSpec.describe "bundle gem" do
- def reset!
- super
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
- end
-
def execute_bundle_gem(gem_name, flag = "")
bundle! "gem #{gem_name} #{flag}"
# reset gemspec cache for each test because of commit 3d4163a
@@ -22,6 +17,7 @@ RSpec.describe "bundle gem" do
end
before do
+ global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
git_config_content = <<-EOF
[user]
name = "Bundler User"
@@ -136,7 +132,6 @@ RSpec.describe "bundle gem" do
context "git config github.user is absent" do
before do
sys_exec("git config --unset github.user")
- reset!
in_app_root
bundle "gem #{gem_name}"
end
@@ -209,7 +204,6 @@ RSpec.describe "bundle gem" do
context "gem naming with relative paths" do
before do
- reset!
in_app_root
end
@@ -281,7 +275,6 @@ RSpec.describe "bundle gem" do
before do
`git config --unset user.name`
`git config --unset user.email`
- reset!
in_app_root
bundle "gem #{gem_name}"
end
@@ -322,7 +315,6 @@ RSpec.describe "bundle gem" do
context "--exe parameter set" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --exe"
end
@@ -338,7 +330,6 @@ RSpec.describe "bundle gem" do
context "--bin parameter set" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --bin"
end
@@ -354,7 +345,6 @@ RSpec.describe "bundle gem" do
context "no --test parameter" do
before do
- reset!
in_app_root
bundle "gem #{gem_name}"
end
@@ -370,7 +360,6 @@ RSpec.describe "bundle gem" do
context "--test parameter set to rspec" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --test=rspec"
end
@@ -397,7 +386,6 @@ RSpec.describe "bundle gem" do
context "gem.test setting set to rspec" do
before do
- reset!
in_app_root
bundle "config set gem.test rspec"
bundle "gem #{gem_name}"
@@ -412,7 +400,6 @@ RSpec.describe "bundle gem" do
context "gem.test setting set to rspec and --test is set to minitest" do
before do
- reset!
in_app_root
bundle "config set gem.test rspec"
bundle "gem #{gem_name} --test=minitest"
@@ -426,7 +413,6 @@ RSpec.describe "bundle gem" do
context "--test parameter set to minitest" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --test=minitest"
end
@@ -456,7 +442,6 @@ RSpec.describe "bundle gem" do
context "gem.test setting set to minitest" do
before do
- reset!
in_app_root
bundle "config set gem.test minitest"
bundle "gem #{gem_name}"
@@ -482,7 +467,6 @@ RSpec.describe "bundle gem" do
context "--test with no arguments" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --test"
end
@@ -499,7 +483,6 @@ RSpec.describe "bundle gem" do
context "--edit option" do
it "opens the generated gemspec in the user's text editor" do
- reset!
in_app_root
output = bundle "gem #{gem_name} --edit=echo"
gemspec_path = File.join(Dir.pwd, gem_name, "#{gem_name}.gemspec")
@@ -515,7 +498,6 @@ RSpec.describe "bundle gem" do
before do
global_config "BUNDLE_GEM__MIT" => "true", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
end
- after { reset! }
it_behaves_like "--mit flag"
it_behaves_like "--no-mit flag"
end
@@ -529,7 +511,6 @@ RSpec.describe "bundle gem" do
before do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "true"
end
- after { reset! }
it_behaves_like "--coc flag"
it_behaves_like "--no-coc flag"
end
@@ -572,7 +553,6 @@ RSpec.describe "bundle gem" do
before do
`git config --unset user.name`
`git config --unset user.email`
- reset!
in_app_root
bundle "gem #{gem_name}"
end
@@ -604,7 +584,6 @@ RSpec.describe "bundle gem" do
context "--bin parameter set" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --bin"
end
@@ -620,7 +599,6 @@ RSpec.describe "bundle gem" do
context "no --test parameter" do
before do
- reset!
in_app_root
bundle "gem #{gem_name}"
end
@@ -636,7 +614,6 @@ RSpec.describe "bundle gem" do
context "--test parameter set to rspec" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --test=rspec"
end
@@ -671,7 +648,6 @@ RSpec.describe "bundle gem" do
context "--test parameter set to minitest" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --test=minitest"
end
@@ -713,7 +689,6 @@ RSpec.describe "bundle gem" do
context "--test with no arguments" do
before do
- reset!
in_app_root
bundle "gem #{gem_name} --test"
end
@@ -726,7 +701,6 @@ RSpec.describe "bundle gem" do
context "--ext parameter set" do
before do
- reset!
in_app_root
bundle "gem test_gem --ext"
end
@@ -770,22 +744,22 @@ RSpec.describe "bundle gem" do
it "fails gracefully with a ." do
bundle "gem foo.gemspec"
- expect(last_command.bundler_err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
+ expect(err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
end
it "fails gracefully with a ^" do
bundle "gem ^"
- expect(last_command.bundler_err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
+ expect(err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
end
it "fails gracefully with a space" do
bundle "gem 'foo bar'"
- expect(last_command.bundler_err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
+ expect(err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
end
it "fails gracefully when multiple names are passed" do
bundle "gem foo bar baz"
- expect(last_command.bundler_err).to eq(<<-E.strip)
+ expect(err).to eq(<<-E.strip)
ERROR: "bundle gem" was called with arguments ["foo", "bar", "baz"]
Usage: "bundle gem NAME [OPTIONS]"
E
@@ -876,7 +850,7 @@ Usage: "bundle gem NAME [OPTIONS]"
FileUtils.touch("conflict-foobar")
end
bundle "gem conflict-foobar"
- expect(last_command.bundler_err).to include("Errno::ENOTDIR")
+ expect(err).to include("Errno::ENOTDIR")
expect(exitstatus).to eql(32) if exitstatus
end
end
@@ -887,7 +861,7 @@ Usage: "bundle gem NAME [OPTIONS]"
FileUtils.mkdir_p("conflict-foobar/Gemfile")
end
bundle! "gem conflict-foobar"
- expect(last_command.stdout).to include("file_clash conflict-foobar/Gemfile").
+ expect(out).to include("file_clash conflict-foobar/Gemfile").
and include "Initializing git repo in #{bundled_app("conflict-foobar")}"
end
end
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
index 843bebf6e0..f0c2927218 100644
--- a/spec/bundler/commands/outdated_spec.rb
+++ b/spec/bundler/commands/outdated_spec.rb
@@ -59,15 +59,19 @@ RSpec.describe "bundle outdated" do
install_gemfile <<-G
source "file://#{gem_repo2}"
+ gem "terranova", '8'
+
group :development, :test do
gem 'activesupport', '2.3.5'
end
G
update_repo2 { build_gem "activesupport", "3.0" }
+ update_repo2 { build_gem "terranova", "9" }
bundle "outdated --verbose"
expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5) in groups \"development, test\"")
+ expect(out).to include("terranova (newest 9, installed 8, requested = 8) in group \"default\"")
end
end
@@ -117,10 +121,10 @@ RSpec.describe "bundle outdated" do
it "returns a sorted list of outdated gems from one group => 'default'" do
test_group_option("default")
- expect(out).to include("===== Group default =====")
+ expect(out).to include("===== Group \"default\" =====")
expect(out).to include("terranova (")
- expect(out).not_to include("===== Group development, test =====")
+ expect(out).not_to include("===== Groups \"development, test\" =====")
expect(out).not_to include("activesupport")
expect(out).not_to include("duradura")
end
@@ -128,10 +132,10 @@ RSpec.describe "bundle outdated" do
it "returns a sorted list of outdated gems from one group => 'development'" do
test_group_option("development", 2)
- expect(out).not_to include("===== Group default =====")
+ expect(out).not_to include("===== Group \"default\" =====")
expect(out).not_to include("terranova (")
- expect(out).to include("===== Group development, test =====")
+ expect(out).to include("===== Groups \"development, test\" =====")
expect(out).to include("activesupport")
expect(out).to include("duradura")
end
@@ -139,10 +143,10 @@ RSpec.describe "bundle outdated" do
it "returns a sorted list of outdated gems from one group => 'test'" do
test_group_option("test", 2)
- expect(out).not_to include("===== Group default =====")
+ expect(out).not_to include("===== Group \"default\" =====")
expect(out).not_to include("terranova (")
- expect(out).to include("===== Group development, test =====")
+ expect(out).to include("===== Groups \"development, test\" =====")
expect(out).to include("activesupport")
expect(out).to include("duradura")
end
@@ -184,9 +188,9 @@ RSpec.describe "bundle outdated" do
end
bundle "outdated --groups"
- expect(out).to include("===== Group default =====")
+ expect(out).to include("===== Group \"default\" =====")
expect(out).to include("terranova (newest 9, installed 8, requested = 8)")
- expect(out).to include("===== Group development, test =====")
+ expect(out).to include("===== Groups \"development, test\" =====")
expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)")
expect(out).to include("duradura (newest 8.0, installed 7.0, requested = 7.0)")
diff --git a/spec/bundler/commands/package_spec.rb b/spec/bundler/commands/package_spec.rb
index 6cd8e3f85a..b9cc079c5c 100644
--- a/spec/bundler/commands/package_spec.rb
+++ b/spec/bundler/commands/package_spec.rb
@@ -278,7 +278,7 @@ RSpec.describe "bundle install with gem sources" do
end
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(the_bundle).to include_gems "rack 1.0"
end
diff --git a/spec/bundler/install/post_bundle_message_spec.rb b/spec/bundler/commands/post_bundle_message_spec.rb
index 1efd0b8146..4d3aa7b450 100644
--- a/spec/bundler/install/post_bundle_message_spec.rb
+++ b/spec/bundler/commands/post_bundle_message_spec.rb
@@ -185,21 +185,21 @@ The source does not contain any versions of 'not-a-gem'
it "with --without one group" do
bundle! :install, forgotten_command_line_options(:without => "emo")
bundle! :update, :all => true
- expect(out).to include("Gems in the group emo were not installed")
+ expect(out).to include("Gems in the group emo were not updated")
expect(out).to include(bundle_updated_message)
end
it "with --without two groups" do
bundle! :install, forgotten_command_line_options(:without => "emo test")
bundle! :update, :all => true
- expect(out).to include("Gems in the groups emo and test were not installed")
+ expect(out).to include("Gems in the groups emo and test were not updated")
expect(out).to include(bundle_updated_message)
end
it "with --without more groups" do
bundle! :install, forgotten_command_line_options(:without => "emo obama test")
bundle! :update, :all => true
- expect(out).to include("Gems in the groups emo, obama and test were not installed")
+ expect(out).to include("Gems in the groups emo, obama and test were not updated")
expect(out).to include(bundle_updated_message)
end
end
diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb
index 6e1986e35f..6a7d5f267e 100644
--- a/spec/bundler/commands/show_spec.rb
+++ b/spec/bundler/commands/show_spec.rb
@@ -30,21 +30,11 @@ RSpec.describe "bundle show", :bundler => "< 3" do
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
- it "prints deprecation" do
- bundle "show rails"
- expect(err).to eq("[DEPRECATED] use `bundle info rails` instead of `bundle show rails`")
- end
-
it "prints path if gem exists in bundle (with --paths option)" do
bundle "show rails --paths"
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
- it "prints deprecation when called with a gem and the --paths option" do
- bundle "show rails --paths"
- expect(err).to eq("[DEPRECATED] use `bundle info rails --path` instead of `bundle show rails --paths`")
- end
-
it "warns if path no longer exists on disk" do
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
@@ -59,10 +49,6 @@ RSpec.describe "bundle show", :bundler => "< 3" do
expect(out).to eq(root.to_s)
end
- it "prints deprecation when called with bundler" do
- bundle "show bundler"
- expect(err).to eq("[DEPRECATED] use `bundle info bundler` instead of `bundle show bundler`")
- end
it "complains if gem not in bundle" do
bundle "show missing"
expect(err).to match(/could not find gem 'missing'/i)
@@ -79,19 +65,26 @@ RSpec.describe "bundle show", :bundler => "< 3" do
expect(gem_list).to eq(gem_list.sort)
end
- it "prints a deprecation when called with the --paths option" do
- bundle "show --paths"
+ it "prints summary of gems" do
+ bundle "show --verbose"
- expect(err).to eq("[DEPRECATED] use `bundle list` instead of `bundle show --paths`")
+ expect(out).to include <<~MSG
+ * actionmailer (2.3.2)
+ \tSummary: This is just a fake gem for testing
+ \tHomepage: http://example.com
+ \tStatus: Up to date
+ MSG
end
- it "prints summary of gems" do
+ it "includes bundler in the summary of gems" do
bundle "show --verbose"
- expect(out).to include("* actionmailer (2.3.2)")
- expect(out).to include("\tSummary: This is just a fake gem for testing")
- expect(out).to include("\tHomepage: No website available.")
- expect(out).to include("\tStatus: Up to date")
+ expect(out).to include <<~MSG
+ * bundler (#{Bundler::VERSION})
+ \tSummary: The best way to manage your application's dependencies
+ \tHomepage: https://bundler.io
+ \tStatus: Up to date
+ MSG
end
end
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 46c208db6c..61a5a1d1f1 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -473,6 +473,39 @@ RSpec.describe "bundle update in more complicated situations" do
expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0"
end
+ it "will not warn when an explicitly updated git gem changes sha but not version" do
+ build_git "foo"
+
+ install_gemfile! <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+
+ update_git "foo" do |s|
+ s.write "lib/foo2.rb", "puts :foo2"
+ end
+
+ bundle! "update foo"
+
+ expect(last_command.stdboth).not_to include "attempted to update"
+ end
+
+ it "will not warn when changing gem sources but not versions" do
+ build_git "rack"
+
+ install_gemfile! <<-G
+ gem "rack", :git => '#{lib_path("rack-1.0")}'
+ G
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle! "update rack"
+
+ expect(last_command.stdboth).not_to include "attempted to update"
+ end
+
it "will update only from pinned source" do
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -530,6 +563,41 @@ RSpec.describe "bundle update in more complicated situations" do
expect(the_bundle).to include_gem "a 1.1"
end
end
+
+ context "when the dependency is for a different platform" do
+ before do
+ build_repo4 do
+ build_gem("a", "0.9") {|s| s.platform = "java" }
+ build_gem("a", "1.1") {|s| s.platform = "java" }
+ end
+
+ gemfile <<-G
+ source "file://#{gem_repo4}"
+ gem "a", platform: :jruby
+ G
+
+ lockfile <<-L
+ GEM
+ remote: file://#{gem_repo4}
+ specs:
+ a (0.9-java)
+
+ PLATFORMS
+ java
+
+ DEPENDENCIES
+ a
+ L
+
+ simulate_platform linux
+ end
+
+ it "is not updated because it is not actually included in the bundle" do
+ bundle! "update a"
+ expect(last_command.stdboth).to include "Bundler attempted to update a but it was not considered because it is for a different platform from the current one"
+ expect(the_bundle).to_not include_gem "a"
+ end
+ end
end
RSpec.describe "bundle update without a Gemfile.lock" do
@@ -565,13 +633,13 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler"
it "should explain that bundler conflicted", :bundler => "< 3" do
bundle "update", :all => true
expect(last_command.stdboth).not_to match(/in snapshot/i)
- expect(last_command.bundler_err).to match(/current Bundler version/i).
+ expect(err).to match(/current Bundler version/i).
and match(/perhaps you need to update bundler/i)
end
it "should warn that the newer version of Bundler would conflict", :bundler => "3" do
bundle! "update", :all => true
- expect(last_command.bundler_err).to include("rails (3.0.1) has dependency bundler").
+ expect(err).to include("rails (3.0.1) has dependency bundler").
and include("so the dependency is being ignored")
expect(the_bundle).to include_gem "rails 3.0.1"
end
@@ -947,7 +1015,7 @@ RSpec.describe "bundle update conservative" do
it "raises if too many flags are provided" do
bundle "update --patch --minor", :all => true
- expect(last_command.bundler_err).to eq "Provide only one of the following options: minor, patch"
+ expect(err).to eq "Provide only one of the following options: minor, patch"
end
end
end
diff --git a/spec/bundler/install/bundler_spec.rb b/spec/bundler/install/bundler_spec.rb
index 3347988cdd..fad6d68010 100644
--- a/spec/bundler/install/bundler_spec.rb
+++ b/spec/bundler/install/bundler_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe "bundle install" do
Could not find gem 'bundler (= 0.9.2)' in any
E
- expect(last_command.bundler_err).to include(nice_error)
+ expect(err).to include(nice_error)
end
it "works for gems with multiple versions in its dependencies" do
@@ -104,7 +104,7 @@ RSpec.describe "bundle install" do
rails_fail was resolved to 1.0, which depends on
activesupport (= 1.2.3)
E
- expect(last_command.bundler_err).to include(nice_error)
+ expect(err).to include(nice_error)
end
it "causes a conflict if a child dependency conflicts with the Gemfile" do
@@ -122,7 +122,7 @@ RSpec.describe "bundle install" do
rails_fail was resolved to 1.0, which depends on
activesupport (= 1.2.3)
E
- expect(last_command.bundler_err).to include(nice_error)
+ expect(err).to include(nice_error)
end
it "can install dependencies with newer bundler version with system gems" do
@@ -140,7 +140,6 @@ RSpec.describe "bundle install" do
it "can install dependencies with newer bundler version with a local path" do
bundle! "config set path .bundle"
- bundle! "config set global_path_appends_ruby_scope true"
install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "rails", "3.0"
diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb
index 0a12b6f116..9569b4d54c 100644
--- a/spec/bundler/install/deploy_spec.rb
+++ b/spec/bundler/install/deploy_spec.rb
@@ -366,7 +366,7 @@ RSpec.describe "install with --deployment or --frozen" do
G
expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(last_command.stderr).to include strip_whitespace(<<-E).strip
+ expect(err).to include strip_whitespace(<<-E).strip
The dependencies in your gemfile changed
You have added to the Gemfile:
diff --git a/spec/bundler/install/failure_spec.rb b/spec/bundler/install/failure_spec.rb
index 49e2771dca..ac3c707187 100644
--- a/spec/bundler/install/failure_spec.rb
+++ b/spec/bundler/install/failure_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe "bundle install" do
source "file:\/\/localhost#{gem_repo2}"
gem "rails"
G
- expect(last_command.bundler_err).to end_with(normalize_uri_file(<<-M.strip))
+ expect(err).to end_with(normalize_uri_file(<<-M.strip))
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.
@@ -46,7 +46,7 @@ In Gemfile:
gem "activesupport", :git => "#{lib_path("activesupport")}"
G
- expect(last_command.bundler_err).to end_with(<<-M.strip)
+ expect(err).to end_with(<<-M.strip)
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
In Gemfile:
@@ -77,7 +77,7 @@ In Gemfile:
end
G
- expect(last_command.bundler_err).to end_with(<<-M.strip)
+ expect(err).to end_with(<<-M.strip)
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
@@ -111,7 +111,7 @@ In Gemfile:
gem "rails"
end
G
- expect(last_command.bundler_err).to end_with(normalize_uri_file(<<-M.strip))
+ expect(err).to end_with(normalize_uri_file(<<-M.strip))
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.
diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb
index 0bec2e9d96..bf1f4d7b9a 100644
--- a/spec/bundler/install/gemfile/gemspec_spec.rb
+++ b/spec/bundler/install/gemfile/gemspec_spec.rb
@@ -65,7 +65,7 @@ RSpec.describe "bundle install from an existing gemspec" do
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}'
G
- expect(last_command.bundler_err).to match(/There are no gemspecs at #{tmp.join('foo')}/)
+ expect(err).to match(/There are no gemspecs at #{tmp.join('foo')}/)
end
it "should raise if there are too many gemspecs available" do
@@ -77,7 +77,7 @@ RSpec.describe "bundle install from an existing gemspec" do
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}'
G
- expect(last_command.bundler_err).to match(/There are multiple gemspecs at #{tmp.join('foo')}/)
+ expect(err).to match(/There are multiple gemspecs at #{tmp.join('foo')}/)
end
it "should pick a specific gemspec" do
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
index c6738686bb..8ca22f1d87 100644
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ b/spec/bundler/install/gemfile/git_spec.rb
@@ -204,7 +204,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
run <<-RUBY
require 'foo'
@@ -234,7 +234,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
run! <<-RUBY
require 'foo'
@@ -270,7 +270,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
run! <<-RUBY
require 'foo'
@@ -515,7 +515,7 @@ RSpec.describe "bundle install with git sources" do
bundle solution
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "explodes and gives correct solution if branch is not given on install" do
@@ -537,7 +537,7 @@ RSpec.describe "bundle install with git sources" do
bundle solution
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "does not explode if disable_local_branch_check is given" do
@@ -1197,7 +1197,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
- expect(last_command.bundler_err).to end_with(<<-M.strip)
+ expect(err).to end_with(<<-M.strip)
An error occurred while installing foo (1.0), and Bundler cannot continue.
In Gemfile:
@@ -1380,7 +1380,7 @@ In Gemfile:
with_path_as("") do
bundle "update", :all => true
end
- expect(last_command.bundler_err).
+ expect(err).
to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git")
end
@@ -1437,7 +1437,7 @@ In Gemfile:
G
expect(last_command.stdboth).to_not include("password1")
- expect(last_command.stdout).to include("Fetching https://user1@github.com/company/private-repo")
+ expect(out).to include("Fetching https://user1@github.com/company/private-repo")
end
end
@@ -1452,7 +1452,7 @@ In Gemfile:
G
expect(last_command.stdboth).to_not include("oauth_token")
- expect(last_command.stdout).to include("Fetching https://x-oauth-basic@github.com/company/private-repo")
+ expect(out).to include("Fetching https://x-oauth-basic@github.com/company/private-repo")
end
end
end
diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb
index 54a41b576f..e80764070c 100644
--- a/spec/bundler/install/gemfile/path_spec.rb
+++ b/spec/bundler/install/gemfile/path_spec.rb
@@ -313,7 +313,7 @@ RSpec.describe "bundle install with explicit source paths" do
install_gemfile <<-G
gem 'foo', '1.0', :path => "#{lib_path("foo-1.0")}"
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "removes the .gem file after installing" do
@@ -484,6 +484,68 @@ RSpec.describe "bundle install with explicit source paths" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
+
+ it "keeps using the same version if it's compatible" do
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
+ s.add_dependency "rack", "0.9.1"
+ end
+
+ bundle "install"
+
+ expect(the_bundle).to include_gems "rack 0.9.1"
+
+ lockfile_should_be <<-G
+ PATH
+ remote: #{lib_path("foo")}
+ specs:
+ foo (1.0)
+ rack (= 0.9.1)
+
+ GEM
+ remote: #{URI.parse("file://#{gem_repo1}/")}
+ specs:
+ rack (0.9.1)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ foo!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+
+ build_lib "foo", "1.0", :path => lib_path("foo") do |s|
+ s.add_dependency "rack"
+ end
+
+ bundle "install"
+
+ lockfile_should_be <<-G
+ PATH
+ remote: #{lib_path("foo")}
+ specs:
+ foo (1.0)
+ rack
+
+ GEM
+ remote: #{URI.parse("file://#{gem_repo1}/")}
+ specs:
+ rack (0.9.1)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ foo!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+
+ expect(the_bundle).to include_gems "rack 0.9.1"
+ end
end
describe "switching sources" do
diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb
index 8e1205dfa3..da364a51bb 100644
--- a/spec/bundler/install/gemfile/sources_spec.rb
+++ b/spec/bundler/install/gemfile/sources_spec.rb
@@ -471,13 +471,13 @@ RSpec.describe "bundle install with gems on multiple sources" do
context "when a single source contains multiple locked gems" do
before do
- # 1. With these gems,
+ # With these gems,
build_repo4 do
build_gem "foo", "0.1"
build_gem "bar", "0.1"
end
- # 2. Installing this gemfile will produce...
+ # Installing this gemfile...
gemfile <<-G
source 'file://#{gem_repo1}'
gem 'rack'
@@ -485,28 +485,9 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem 'bar', '~> 0.1', :source => 'file://#{gem_repo4}'
G
- # 3. this lockfile.
- lockfile <<-L
- GEM
- remote: file:/Users/andre/src/bundler/bundler/tmp/gems/remote1/
- remote: file:/Users/andre/src/bundler/bundler/tmp/gems/remote4/
- specs:
- bar (0.1)
- foo (0.1)
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- bar (~> 0.1)!
- foo (~> 0.1)!
- rack
- L
-
bundle! :install, forgotten_command_line_options(:path => "../gems/system")
- # 4. Then we add some new versions...
+ # And then we add some new versions...
update_repo4 do
build_gem "foo", "0.2"
build_gem "bar", "0.3"
@@ -514,7 +495,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
it "allows them to be unlocked separately" do
- # 5. and install this gemfile, updating only foo.
+ # And install this gemfile, updating only foo.
install_gemfile <<-G
source 'file://#{gem_repo1}'
gem 'rack'
@@ -522,7 +503,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem 'bar', '~> 0.1', :source => 'file://#{gem_repo4}'
G
- # 6. Which should update foo to 0.2, but not the (locked) bar 0.1
+ # It should update foo to 0.2, but not the (locked) bar 0.1
expect(the_bundle).to include_gems("foo 0.2", "bar 0.1")
end
end
@@ -578,7 +559,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
# When this gemfile is installed...
- gemfile <<-G
+ install_gemfile <<-G
source "#{source_uri}"
source "#{second_uri}" do
@@ -588,26 +569,6 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "rack-obama"
G
- # It creates this lockfile.
- lockfile <<-L
- GEM
- remote: #{source_uri}/
- remote: #{second_uri}/
- specs:
- rack (2.0.1.1.forked)
- rack-obama (1.0)
- rack
- thor (0.19.1.1.forked)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (= 2.0.1.1.forked)!
- rack-obama
- thor!
- L
-
# Then we change the Gemfile by adding a version to thor
gemfile <<-G
source "#{source_uri}"
diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb
index b94b68dbd9..e35b630306 100644
--- a/spec/bundler/install/gems/compact_index_spec.rb
+++ b/spec/bundler/install/gems/compact_index_spec.rb
@@ -60,7 +60,7 @@ RSpec.describe "compact index api" do
# can't use `include_gems` here since the `require` will conflict on a
# case-insensitive FS
run! "Bundler.require; puts Gem.loaded_specs.values_at('rack', 'Rack').map(&:full_name)"
- expect(last_command.stdout).to eq("rack-1.0\nRack-0.1")
+ expect(out).to eq("rack-1.0\nRack-0.1")
end
it "should handle multiple gem dependencies on the same gem" do
diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb
index aeb83d6573..d15841124a 100644
--- a/spec/bundler/install/gems/flex_spec.rb
+++ b/spec/bundler/install/gems/flex_spec.rb
@@ -188,7 +188,7 @@ RSpec.describe "bundle flex_install" do
ruby <<-RUBY
require 'bundler/setup'
RUBY
- expect(last_command.stderr).to match(/could not find gem 'rack-obama/i)
+ expect(err).to match(/could not find gem 'rack-obama/i)
end
it "suggests bundle update when the Gemfile requires different versions than the lock" do
@@ -209,7 +209,7 @@ RSpec.describe "bundle flex_install" do
E
bundle :install, :retry => 0
- expect(last_command.bundler_err).to end_with(nice_error)
+ expect(err).to end_with(nice_error)
end
end
diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb
index cf3aaa719e..7bab676cea 100644
--- a/spec/bundler/install/gems/resolving_spec.rb
+++ b/spec/bundler/install/gems/resolving_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle :install, :env => { "DEBUG_RESOLVER" => "1" }
- expect(last_command.stderr).to include("Creating possibility state for net_c")
+ expect(err).to include("Creating possibility state for net_c")
end
end
@@ -91,7 +91,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
- expect(last_command.stderr).to include(" net_b").
+ expect(err).to include(" net_b").
and include("Starting resolution").
and include("Finished resolution").
and include("Attempting to activate")
@@ -171,7 +171,7 @@ RSpec.describe "bundle install with install-time dependencies" do
Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
E
- expect(last_command.bundler_err).to end_with(nice_error)
+ expect(err).to end_with(nice_error)
end
end
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index e2cfe5ec4c..68796977a4 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -175,8 +175,8 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
- expect(last_command.stderr).to eq("ZOMG LOAD ERROR")
+ expect(out).to eq("2.3.2")
+ expect(err).to eq("ZOMG LOAD ERROR")
end
it "allows --without to limit the groups used in a standalone" do
@@ -193,8 +193,8 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
- expect(last_command.stderr).to eq("ZOMG LOAD ERROR")
+ expect(out).to eq("2.3.2")
+ expect(err).to eq("ZOMG LOAD ERROR")
end
it "allows --path to change the location of the standalone bundle", :bundler => "< 3" do
@@ -210,7 +210,7 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
+ expect(out).to eq("2.3.2")
end
it "allows --path to change the location of the standalone bundle", :bundler => "3" do
@@ -227,7 +227,7 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
+ expect(out).to eq("2.3.2")
end
it "allows remembered --without to limit the groups used in a standalone" do
@@ -245,8 +245,8 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
- expect(last_command.stderr).to eq("ZOMG LOAD ERROR")
+ expect(out).to eq("2.3.2")
+ expect(err).to eq("ZOMG LOAD ERROR")
end
end
diff --git a/spec/bundler/install/gems/sudo_spec.rb b/spec/bundler/install/gems/sudo_spec.rb
index fb41f63a07..0d2d6b7eb4 100644
--- a/spec/bundler/install/gems/sudo_spec.rb
+++ b/spec/bundler/install/gems/sudo_spec.rb
@@ -3,13 +3,20 @@
RSpec.describe "when using sudo", :sudo => true do
describe "and BUNDLE_PATH is writable" do
context "but BUNDLE_PATH/build_info is not writable" do
+ let(:subdir) do
+ system_gem_path("cache")
+ end
+
before do
bundle! "config set path.system true"
- subdir = system_gem_path("cache")
subdir.mkpath
sudo "chmod u-w #{subdir}"
end
+ after do
+ sudo "chmod u+w #{subdir}"
+ end
+
it "installs" do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -52,8 +59,6 @@ RSpec.describe "when using sudo", :sudo => true do
end
it "installs when BUNDLE_PATH is owned by root" do
- bundle! "config set global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
-
bundle_path = tmp("owned_by_root")
FileUtils.mkdir_p bundle_path
sudo "chown -R root #{bundle_path}"
@@ -64,14 +69,12 @@ RSpec.describe "when using sudo", :sudo => true do
gem "rack", '1.0'
G
- expect(bundle_path.join("gems/rack-1.0.0")).to exist
- expect(bundle_path.join("gems/rack-1.0.0").stat.uid).to eq(0)
+ expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0")).to exist
+ expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0").stat.uid).to eq(0)
expect(the_bundle).to include_gems "rack 1.0"
end
it "installs when BUNDLE_PATH does not exist" do
- bundle! "config set global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
-
root_path = tmp("owned_by_root")
FileUtils.mkdir_p root_path
sudo "chown -R root #{root_path}"
@@ -83,8 +86,8 @@ RSpec.describe "when using sudo", :sudo => true do
gem "rack", '1.0'
G
- expect(bundle_path.join("gems/rack-1.0.0")).to exist
- expect(bundle_path.join("gems/rack-1.0.0").stat.uid).to eq(0)
+ expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0")).to exist
+ expect(bundle_path.join(Bundler.ruby_scope, "gems/rack-1.0.0").stat.uid).to eq(0)
expect(the_bundle).to include_gems "rack 1.0"
end
@@ -105,6 +108,10 @@ RSpec.describe "when using sudo", :sudo => true do
sudo "chmod ugo-w #{default_bundle_path}"
end
+ after do
+ sudo "chmod ugo+w #{default_bundle_path}"
+ end
+
it "installs" do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -146,6 +153,8 @@ RSpec.describe "when using sudo", :sudo => true do
bundle :install, :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
expect(gem_home.join("bin/rackup")).to exist
expect(the_bundle).to include_gems "rack 1.0", :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
+
+ sudo "rm -rf #{tmp("sudo_gem_home")}"
end
end
diff --git a/spec/bundler/install/gemspecs_spec.rb b/spec/bundler/install/gemspecs_spec.rb
index c9878ccae8..55c7a67b4b 100644
--- a/spec/bundler/install/gemspecs_spec.rb
+++ b/spec/bundler/install/gemspecs_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe "bundle install" do
gem "yaml_spec"
G
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "still installs correctly when using path" do
@@ -23,7 +23,7 @@ RSpec.describe "bundle install" do
install_gemfile <<-G
gem 'yaml_spec', :path => "#{lib_path("yaml_spec-1.0")}"
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
diff --git a/spec/bundler/install/path_spec.rb b/spec/bundler/install/path_spec.rb
index 0947ed9539..b2a3375342 100644
--- a/spec/bundler/install/path_spec.rb
+++ b/spec/bundler/install/path_spec.rb
@@ -113,71 +113,36 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
- context "with global_path_appends_ruby_scope set", :bundler => "3" do
- it "installs gems to ." do
- set_bundle_path(type, ".")
- bundle! "config set --global disable_shared_gems true"
+ it "installs gems to ." do
+ set_bundle_path(type, ".")
+ bundle! "config set --global disable_shared_gems true"
- bundle! :install
-
- paths_to_exist = %w[cache/rack-1.0.0.gem gems/rack-1.0.0 specifications/rack-1.0.0.gemspec].map {|path| bundled_app(Bundler.ruby_scope, path) }
- expect(paths_to_exist).to all exist
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs gems to the path" do
- set_bundle_path(type, bundled_app("vendor").to_s)
-
- bundle! :install
+ bundle! :install
- expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
+ paths_to_exist = %w[cache/rack-1.0.0.gem gems/rack-1.0.0 specifications/rack-1.0.0.gemspec].map {|path| bundled_app(Bundler.ruby_scope, path) }
+ expect(paths_to_exist).to all exist
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
- it "installs gems to the path relative to root when relative" do
- set_bundle_path(type, "vendor")
+ it "installs gems to the path" do
+ set_bundle_path(type, bundled_app("vendor").to_s)
- FileUtils.mkdir_p bundled_app("lol")
- Dir.chdir(bundled_app("lol")) do
- bundle! :install
- end
+ bundle! :install
- expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
+ expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
- context "with global_path_appends_ruby_scope unset", :bundler => "< 3" do
- it "installs gems to ." do
- set_bundle_path(type, ".")
- bundle! "config set --global disable_shared_gems true"
+ it "installs gems to the path relative to root when relative" do
+ set_bundle_path(type, "vendor")
+ FileUtils.mkdir_p bundled_app("lol")
+ Dir.chdir(bundled_app("lol")) do
bundle! :install
-
- expect([bundled_app("cache/rack-1.0.0.gem"), bundled_app("gems/rack-1.0.0"), bundled_app("specifications/rack-1.0.0.gemspec")]).to all exist
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "installs gems to BUNDLE_PATH with #{type}" do
- set_bundle_path(type, bundled_app("vendor").to_s)
-
- bundle :install
-
- expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
end
- it "installs gems to BUNDLE_PATH relative to root when relative" do
- set_bundle_path(type, "vendor")
-
- FileUtils.mkdir_p bundled_app("lol")
- Dir.chdir(bundled_app("lol")) do
- bundle :install
- end
-
- expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
+ expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
@@ -226,7 +191,7 @@ RSpec.describe "bundle install" do
vendored_gems("extensions").rmtree
run "require 'very_simple_binary_c'"
- expect(last_command.stderr).to include("Bundler::GemNotFound")
+ expect(err).to include("Bundler::GemNotFound")
bundle :install, forgotten_command_line_options(:path => "./vendor/bundle")
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
index 5ee44bf779..c2d44e5cf1 100644
--- a/spec/bundler/lock/lockfile_spec.rb
+++ b/spec/bundler/lock/lockfile_spec.rb
@@ -154,7 +154,10 @@ RSpec.describe "the lockfile format" do
G
end
- it "outputs a warning if the current is older than lockfile's bundler version" do
+ it "warns if the current is older than lockfile's bundler version" do
+ current_version = Bundler::VERSION
+ newer_minor = bump_minor(current_version)
+
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
@@ -162,28 +165,27 @@ RSpec.describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic_local_platform}
+ #{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
- 9999999.1.0
+ #{newer_minor}
L
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo1}"
- gem "rack"
- G
- end
+ gem "rack"
+ G
- warning_message = "the running version of Bundler (9999999.0.0) is older " \
- "than the version that created the lockfile (9999999.1.0). " \
+ pre_flag = prerelease?(newer_minor) ? " --pre" : ""
+ warning_message = "the running version of Bundler (#{current_version}) is older " \
+ "than the version that created the lockfile (#{newer_minor}). " \
"We suggest you to upgrade to the version that created the " \
- "lockfile by running `gem install bundler:9999999.1.0`."
- expect(last_command.stderr).to include warning_message
+ "lockfile by running `gem install bundler:#{newer_minor}#{pre_flag}`."
+ expect(err).to include warning_message
lockfile_should_be <<-G
GEM
@@ -192,18 +194,20 @@ RSpec.describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic_local_platform}
- #{specific_local_platform}
+ #{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
- 9999999.1.0
+ #{newer_minor}
G
end
- it "errors if the current is a major version older than lockfile's bundler version", :bundler => "3" do
+ it "warns when updating bundler major version" do
+ current_version = Bundler::VERSION
+ older_major = previous_major(current_version)
+
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
@@ -217,7 +221,7 @@ RSpec.describe "the lockfile format" do
rack
BUNDLED WITH
- 9999999.0.0
+ #{older_major}
L
install_gemfile <<-G
@@ -226,76 +230,9 @@ RSpec.describe "the lockfile format" do
gem "rack"
G
- expect(last_command).to be_failure
- expect(last_command.bundler_err).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "shows a friendly error when running with a new bundler 2 lockfile" do
- lockfile <<-L
- GEM
- remote: https://rails-assets.org/
- specs:
- rails-assets-bootstrap (3.3.4)
- rails-assets-jquery (>= 1.9.1)
- rails-assets-jquery (2.1.4)
-
- GEM
- remote: https://rubygems.org/
- specs:
- rake (10.4.2)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rails-assets-bootstrap!
- rake
-
- BUNDLED WITH
- 9999999.0.0
- L
-
- install_gemfile <<-G
- source 'https://rubygems.org'
- gem 'rake'
-
- source 'https://rails-assets.org' do
- gem 'rails-assets-bootstrap'
- end
- G
-
- expect(last_command).to be_failure
- expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "warns when updating bundler major version", :bundler => "< 3" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 1.10.0
- L
-
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}/"
-
- gem "rack"
- G
- end
-
- expect(last_command.stderr).to include(
+ expect(err).to include(
"Warning: the lockfile is being updated to Bundler " \
- "9999999, after which you will be unable to return to Bundler 1."
+ "#{current_version.split(".").first}, after which you will be unable to return to Bundler #{older_major.split(".").first}."
)
lockfile_should_be <<-G
@@ -305,62 +242,14 @@ RSpec.describe "the lockfile format" do
rack (1.0.0)
PLATFORMS
- #{generic_local_platform}
- #{specific_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.0.0
- G
- end
-
- it "warns when updating bundler major version", :bundler => "3" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
- 1.10.0
- L
-
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}/"
-
- gem "rack"
- G
-
- expect(last_command.stderr).to include(
- "Warning: the lockfile is being updated to Bundler " \
- "9999999, after which you will be unable to return to Bundler 1."
- )
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{lockfile_platforms}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.0.0
- G
- end
+ #{current_version}
+ G
end
it "generates a simple lockfile for a single source, gem with dependencies" do
@@ -1579,7 +1468,25 @@ RSpec.describe "the lockfile format" do
gem "rack"
G
- expect(last_command.bundler_err).to match(/your Gemfile.lock contains merge conflicts/i)
- expect(last_command.bundler_err).to match(/git checkout HEAD -- Gemfile.lock/i)
+ expect(err).to match(/your Gemfile.lock contains merge conflicts/i)
+ expect(err).to match(/git checkout HEAD -- Gemfile.lock/i)
+ end
+
+private
+
+ def prerelease?(version)
+ Gem::Version.new(version).prerelease?
+ end
+
+ def previous_major(version)
+ version.split(".").map.with_index {|v, i| i == 0 ? v.to_i - 1 : v }.join(".")
+ end
+
+ def bump_minor(version)
+ bump(version, 1)
+ end
+
+ def bump(version, segment)
+ version.split(".").map.with_index {|v, i| i == segment ? v.to_i + 1 : v }.join(".")
end
end
diff --git a/spec/bundler/other/cli_dispatch_spec.rb b/spec/bundler/other/cli_dispatch_spec.rb
index 67127fc6e0..548539ac89 100644
--- a/spec/bundler/other/cli_dispatch_spec.rb
+++ b/spec/bundler/other/cli_dispatch_spec.rb
@@ -3,19 +3,19 @@
RSpec.describe "bundle command names" do
it "work when given fully" do
bundle "install"
- expect(last_command.bundler_err).to eq("Could not locate Gemfile")
+ expect(err).to eq("Could not locate Gemfile")
expect(last_command.stdboth).not_to include("Ambiguous command")
end
it "work when not ambiguous" do
bundle "ins"
- expect(last_command.bundler_err).to eq("Could not locate Gemfile")
+ expect(err).to eq("Could not locate Gemfile")
expect(last_command.stdboth).not_to include("Ambiguous command")
end
it "print a friendly error when ambiguous" do
bundle "in"
- expect(last_command.bundler_err).to eq("Ambiguous command in matches [info, init, inject, install]")
+ expect(err).to eq("Ambiguous command in matches [info, init, inject, install]")
end
context "when cache_command_is_package is set" do
@@ -23,7 +23,7 @@ RSpec.describe "bundle command names" do
it "dispatches `bundle cache` to the package command" do
bundle "cache --verbose"
- expect(last_command.stdout).to start_with "Running `bundle package --verbose`"
+ expect(out).to start_with "Running `bundle package --verbose`"
end
end
end
diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb
index 83944e4075..fd12c645a8 100644
--- a/spec/bundler/other/major_deprecation_spec.rb
+++ b/spec/bundler/other/major_deprecation_spec.rb
@@ -365,38 +365,30 @@ RSpec.describe "major deprecations" do
end
describe Bundler::Dsl do
- let(:msg) do
- <<-EOS
-The :github git source is deprecated, and will be removed in the future. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
-
- git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
-
- EOS
- end
-
before do
@rubygems = double("rubygems")
allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems }
end
context "with github gems" do
- it "warns about the https change if people are opting out" do
- Bundler.settings.temporary "github.https" => false
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "Setting `github.https` to false is deprecated and won't be supported in the future.")
- subject.gem("sparks", :github => "indirect/sparks")
- end
+ it "warns about removal", :bundler => "2" do
+ msg = <<-EOS
+The :github git source is deprecated, and will be removed in the future. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
- it "upgrades to https by default", :bundler => "2" do
+ git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
+
+ EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
subject.gem("sparks", :github => "indirect/sparks")
github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
+
+ pending "should fail with a helpful error", :bundler => "3"
end
context "with bitbucket gems" do
- it "warns about removal" do
+ it "warns about removal", :bundler => "2" do
allow(Bundler.ui).to receive(:deprecate)
msg = <<-EOS
The :bitbucket git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
@@ -411,10 +403,12 @@ The :bitbucket git source is deprecated, and will be removed in the future. Add
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
end
+
+ pending "should fail with a helpful error", :bundler => "3"
end
context "with gist gems" do
- it "warns about removal" do
+ it "warns about removal", :bundler => "2" do
allow(Bundler.ui).to receive(:deprecate)
msg = <<-EOS
The :gist git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
@@ -425,6 +419,8 @@ The :gist git source is deprecated, and will be removed in the future. Add this
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
subject.gem("not-really-a-gem", :gist => "1234")
end
+
+ pending "should fail with a helpful error", :bundler => "3"
end
end
@@ -480,9 +476,33 @@ The :gist git source is deprecated, and will be removed in the future. Add this
it "prints a deprecation warning recommending `bundle info`", :bundler => "2" do
expect(deprecations).to include("use `bundle info rack` instead of `bundle show rack`")
end
+
+ pending "fails with a helpful message", :bundler => "3"
+ end
+
+ context "with the --paths option" do
+ before do
+ bundle "show --paths"
+ end
+
+ it "prints a deprecation warning recommending `bundle list`", :bundler => "2" do
+ expect(deprecations).to include("use `bundle list` instead of `bundle show --paths`")
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
end
- pending "fails with a helpful message", :bundler => "3"
+ context "with a gem argument and the --paths option" do
+ before do
+ bundle "show rack --paths"
+ end
+
+ it "prints deprecation warning recommending `bundle info`", :bundler => "2" do
+ expect(deprecations).to include("use `bundle info rack --path` instead of `bundle show rack --paths`")
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
+ end
end
context "bundle console" do
diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb
index ca622508c6..b8f2d6ed1b 100644
--- a/spec/bundler/quality_spec.rb
+++ b/spec/bundler/quality_spec.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "set"
+
if defined?(Encoding) && Encoding.default_external.name != "UTF-8"
# An approximation of ruby -E UTF-8, since it works on 1.8.7
Encoding.default_external = Encoding.find("UTF-8")
@@ -171,7 +173,6 @@ RSpec.describe "The library itself" do
forget_cli_options
gem.coc
gem.mit
- github.https
inline
use_gem_version_promoter_for_major_updates
]
@@ -225,9 +226,9 @@ RSpec.describe "The library itself" do
end
# there's no way around this warning
- last_command.stderr.sub!(/^YAML safe loading.*/, "")
+ err.sub!(/^YAML safe loading.*/, "")
- expect(last_command.stderr).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
+ expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
ensure
# clean up the .gem generated
FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
@@ -273,4 +274,20 @@ RSpec.describe "The library itself" do
expect(warnings).to be_well_formed
end
end
+
+ it "does not use require internally, but require_relative" do
+ Dir.chdir(root) do
+ exempt = %r{templates/|vendor/}
+ all_bad_requires = []
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ File.readlines(filename).each_with_index do |line, number|
+ line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
+ end
+ end
+
+ expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}"
+ end
+ end
end
diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb
index a3662c91e7..6468ee7f1e 100644
--- a/spec/bundler/realworld/edgecases_spec.rb
+++ b/spec/bundler/realworld/edgecases_spec.rb
@@ -204,7 +204,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
bundle "config set --local path vendor/bundle"
bundle! :install
expect(err).not_to include("Could not find rake")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "checks out git repos when the lockfile is corrupted" do
@@ -331,7 +331,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
L
bundle! :lock
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "outputs a helpful error message when gems have invalid gemspecs" do
diff --git a/spec/bundler/realworld/gemfile_source_header_spec.rb b/spec/bundler/realworld/gemfile_source_header_spec.rb
index eaefd0f03e..382485b8fc 100644
--- a/spec/bundler/realworld/gemfile_source_header_spec.rb
+++ b/spec/bundler/realworld/gemfile_source_header_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe "fetching dependencies with a mirrored source", :realworld => tru
expect(the_bundle).to include_gems "weakling 0.0.3"
end
- private
+private
def setup_server
require_rack
diff --git a/spec/bundler/realworld/mirror_probe_spec.rb b/spec/bundler/realworld/mirror_probe_spec.rb
index c5e95f3059..13d1afe124 100644
--- a/spec/bundler/realworld/mirror_probe_spec.rb
+++ b/spec/bundler/realworld/mirror_probe_spec.rb
@@ -86,8 +86,8 @@ RSpec.describe "fetching dependencies with a not available mirror", :realworld =
bundle :install, :artifice => nil
- expect(last_command.stdout).to include "Fetching source index from #{mirror}/"
- expect(last_command.bundler_err).to include <<-EOS.strip
+ expect(out).to include "Fetching source index from #{mirror}/"
+ expect(err).to include <<-EOS.strip
Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
index 7026474b0e..eb9db56ead 100644
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ b/spec/bundler/runtime/gem_tasks_spec.rb
@@ -19,10 +19,10 @@ RSpec.describe "require 'bundler/gem_tasks'" do
it "includes the relevant tasks" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec "#{rake} -T"
+ sys_exec "#{rake} -T", "RUBYOPT" => "-I#{bundler_path}"
end
- expect(last_command.stderr).to eq("")
+ expect(err).to eq("")
expected_tasks = [
"rake build",
"rake clean",
@@ -39,6 +39,6 @@ RSpec.describe "require 'bundler/gem_tasks'" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
end
- expect(last_command.stdout).to eq '["pkg"]'
+ expect(out).to eq '["pkg"]'
end
end
diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb
index 96a3fa09ae..d53c3d1c15 100644
--- a/spec/bundler/runtime/inline_spec.rb
+++ b/spec/bundler/runtime/inline_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(last_command.stderr).to include "Could not find gem 'eleven'"
+ expect(err).to include "Could not find gem 'eleven'"
expect(out).not_to include "success"
script <<-RUBY
@@ -90,7 +90,7 @@ RSpec.describe "bundler/inline#gemfile" do
expect(out).to include("Installing activesupport")
err.gsub! %r{.*lib/sinatra/base\.rb:\d+: warning: constant ::Fixnum is deprecated$}, ""
err.strip!
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -134,7 +134,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(last_command.stderr).to include "Unknown options: arglebargle"
+ expect(err).to include "Unknown options: arglebargle"
expect(out).not_to include "success"
end
@@ -165,7 +165,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -183,7 +183,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0\n2.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -203,7 +203,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("two\nfour")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -240,6 +240,20 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
+ expect(err).to be_empty
+ expect(exitstatus).to be_zero if exitstatus
+ end
+
+ it "installs inline gems when frozen is set" do
+ script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" }
+ gemfile do
+ source "file://#{gem_repo1}"
+ gem "rack"
+ end
+
+ puts RACK
+ RUBY
+
expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -258,7 +272,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -274,6 +288,19 @@ RSpec.describe "bundler/inline#gemfile" do
puts RACK
RUBY
expect(last_command).to be_success
- expect(last_command.stdout).to eq "1.0.0"
+ expect(out).to eq "1.0.0"
+ end
+
+ it "skips platform warnings" do
+ simulate_platform "ruby"
+
+ script <<-RUBY
+ gemfile(true) do
+ source "file://#{gem_repo1}"
+ gem "rack", platform: :jruby
+ end
+ RUBY
+
+ expect(err).to be_empty
end
end
diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb
index c9cfa199d3..f149c9d489 100644
--- a/spec/bundler/runtime/require_spec.rb
+++ b/spec/bundler/runtime/require_spec.rb
@@ -136,8 +136,8 @@ RSpec.describe "Bundler.require" do
G
run "Bundler.require"
- expect(last_command.stderr).to match("error while trying to load the gem 'faulty'")
- expect(last_command.stderr).to match("Gem Internal Error Message")
+ expect(err).to match("error while trying to load the gem 'faulty'")
+ expect(err).to match("Gem Internal Error Message")
end
it "doesn't swallow the error when the library has an unrelated error" do
@@ -198,7 +198,7 @@ RSpec.describe "Bundler.require" do
RUBY
ruby(cmd)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "does not mangle explicitly given requires" do
@@ -432,7 +432,7 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
G
run "Bundler.require"
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "requires gems pinned to multiple platforms, including the current one" do
@@ -447,6 +447,6 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
run "Bundler.require; puts RACK"
expect(out).to eq("1.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index c81baa34ea..90c3df8661 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
end
@@ -45,7 +45,7 @@ RSpec.describe "Bundler.setup" do
puts "WIN"
end
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("WIN")
end
@@ -58,7 +58,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
@@ -72,7 +72,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
@@ -90,7 +90,7 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
end
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to match("WIN")
end
@@ -104,8 +104,8 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
RUBY
- expect(last_command.stderr).to match("rack")
- expect(last_command.stderr).to match("LoadError")
+ expect(err).to match("rack")
+ expect(err).to match("LoadError")
expect(out).not_to match("FAIL")
end
end
@@ -141,7 +141,7 @@ RSpec.describe "Bundler.setup" do
load_path = out.split("\n")
rack_load_order = load_path.index {|path| path.include?("rack") }
- expect(last_command.stderr).to eq("")
+ expect(err).to eq("")
expect(load_path).to include(a_string_ending_with("dash_i_dir"), "rubylib_dir")
expect(rack_load_order).to be > 0
end
@@ -364,7 +364,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "replaces #gem but raises when the version is wrong" do
@@ -390,7 +390,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -449,7 +449,7 @@ RSpec.describe "Bundler.setup" do
it "provides a useful exception when the git repo is not checked out yet" do
run "1"
- expect(last_command.stderr).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
+ expect(err).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
end
it "does not hit the git binary if the lockfile is available and up to date" do
@@ -535,7 +535,7 @@ RSpec.describe "Bundler.setup" do
FileUtils.rm_rf(lib_path("local-rack"))
run "require 'rack'"
- expect(last_command.stderr).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
+ expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
end
it "explodes if branch is not given on runtime" do
@@ -557,7 +557,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(last_command.stderr).to match(/because :branch is not specified in Gemfile/)
+ expect(err).to match(/because :branch is not specified in Gemfile/)
end
it "explodes on different branches on runtime" do
@@ -579,7 +579,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(last_command.stderr).to match(/is using branch master but Gemfile specifies changed/)
+ expect(err).to match(/is using branch master but Gemfile specifies changed/)
end
it "explodes on refs with different branches on runtime" do
@@ -599,7 +599,7 @@ RSpec.describe "Bundler.setup" do
bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
- expect(last_command.stderr).to match(/is using branch master but Gemfile specifies nonexistant/)
+ expect(err).to match(/is using branch master but Gemfile specifies nonexistant/)
end
end
@@ -711,7 +711,7 @@ end
ENV["GEM_HOME"] = ""
bundle %(exec ruby -e "require 'set'")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
describe "$MANPATH" do
@@ -878,7 +878,7 @@ end
require 'foo'
R
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
@@ -903,7 +903,7 @@ end
R
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -1053,7 +1053,7 @@ end
Bundler.load
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("")
end
end
@@ -1065,7 +1065,7 @@ end
G
bundle %(exec ruby -e "require 'bundler'; Bundler.setup")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -1260,14 +1260,14 @@ end
it "activates no gems with -rbundler/setup" do
install_gemfile! ""
ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -rbundler/setup" }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
it "activates no gems with bundle exec" do
install_gemfile! ""
create_file("script.rb", code)
bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
it "activates no gems with bundle exec that is loaded" do
@@ -1275,7 +1275,7 @@ end
create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}")
FileUtils.chmod(0o777, bundled_app("script.rb"))
bundle! "exec ./script.rb", :artifice => nil, :env => { :RUBYOPT => activation_warning_hack_rubyopt }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
let(:default_gems) do
@@ -1355,7 +1355,7 @@ end
RUBY
expect(last_command.stdboth).not_to include "FAIL"
- expect(last_command.stderr).to include "private method `gem'"
+ expect(err).to include "private method `gem'"
end
it "keeps Kernel#require private" do
@@ -1371,7 +1371,7 @@ end
RUBY
expect(last_command.stdboth).not_to include "FAIL"
- expect(last_command.stderr).to include "private method `require'"
+ expect(err).to include "private method `require'"
end
end
end
diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb
index b4503cba32..b901f28c8b 100644
--- a/spec/bundler/runtime/with_unbundled_env_spec.rb
+++ b/spec/bundler/runtime/with_unbundled_env_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe "Bundler.with_env helpers" do
build_bundler_context
bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2"
end
- expect(last_command.stderr).to eq <<-EOS.strip
+ expect(err).to eq <<-EOS.strip
2 false
1 true
0 true
@@ -153,29 +153,50 @@ RSpec.describe "Bundler.with_env helpers" do
end
describe "Bundler.original_system" do
+ let(:code) do
+ <<~RUBY
+ Bundler.original_system(%([ "\$BUNDLE_FOO" = "bar" ] && exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
it "runs system inside with_original_env" do
- code = 'exit Bundler.original_system(%(test "\$BUNDLE_FOO" = "bar"))'
lib = File.expand_path("../../lib", __dir__)
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(0)
+ expect($?.exitstatus).to eq(42)
end
end
describe "Bundler.clean_system", :bundler => 2 do
+ let(:code) do
+ <<~RUBY
+ Bundler.clean_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
it "runs system inside with_clean_env" do
- code = 'exit Bundler.clean_system(%(test "\$BUNDLE_FOO" = "bar"))'
lib = File.expand_path("../../lib", __dir__)
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(1)
+ expect($?.exitstatus).to eq(42)
end
end
describe "Bundler.unbundled_system" do
+ let(:code) do
+ <<~RUBY
+ Bundler.unbundled_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
it "runs system inside with_unbundled_env" do
- code = 'exit Bundler.clean_system(%(test "\$BUNDLE_FOO" = "bar"))'
lib = File.expand_path("../../lib", __dir__)
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(1)
+ expect($?.exitstatus).to eq(42)
end
end
diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb
index e8e7cc9a1f..d3de1ff784 100644
--- a/spec/bundler/spec_helper.rb
+++ b/spec/bundler/spec_helper.rb
@@ -23,14 +23,6 @@ end
$debug = false
Spec::Manpages.setup unless Gem.win_platform?
-Spec::Rubygems.setup
-ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
-ENV["BUNDLE_SPEC_RUN"] = "true"
-
-# Don't wrap output in tests
-ENV["THOR_COLUMNS"] = "10000"
-
-Spec::CodeClimate.setup
module Gem
def self.ruby=(ruby)
@@ -60,6 +52,8 @@ RSpec.configure do |config|
# forever due to memory constraints
config.fail_fast ||= 25 if ENV["CI"]
+ config.bisect_runner = :shell
+
if ENV["BUNDLER_SUDO_TESTS"] && Spec::Sudo.present?
config.filter_run :sudo => true
else
@@ -72,8 +66,11 @@ RSpec.configure do |config|
config.filter_run_excluding :realworld => true
end
+ git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version
+
config.filter_run_excluding :ruby => RequirementChecker.against(RUBY_VERSION)
config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION)
+ config.filter_run_excluding :git => RequirementChecker.against(git_version)
config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master")
config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil?
@@ -101,6 +98,15 @@ RSpec.configure do |config|
end
config.before :suite do
+ Spec::Rubygems.setup
+ ENV["RUBYOPT"] = original_env["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
+ ENV["BUNDLE_SPEC_RUN"] = original_env["BUNDLE_SPEC_RUN"] = "true"
+
+ # Don't wrap output in tests
+ ENV["THOR_COLUMNS"] = "10000"
+
+ original_env = ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }
+
if ENV["BUNDLE_RUBY"]
FileUtils.cp_r Spec::Path.bindir, File.join(Spec::Path.root, "lib", "exe")
end
@@ -110,14 +116,15 @@ RSpec.configure do |config|
build_repo1
end
- config.before :each do
+ config.around :each do |example|
+ ENV.replace(original_env)
reset!
system_gems []
in_app_root
@command_executions = []
- end
- config.after :each do |example|
+ example.run
+
all_output = @command_executions.map(&:to_s_verbose).join("\n\n")
if example.exception && !all_output.empty?
warn all_output unless config.formatters.grep(RSpec::Core::Formatters::DocumentationFormatter).empty?
@@ -128,7 +135,6 @@ RSpec.configure do |config|
end
Dir.chdir(original_wd)
- ENV.replace(original_env)
end
config.after :suite do
diff --git a/spec/bundler/support/code_climate.rb b/spec/bundler/support/code_climate.rb
deleted file mode 100644
index a15442cabe..0000000000
--- a/spec/bundler/support/code_climate.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-module Spec
- module CodeClimate
- def self.setup
- require "codeclimate-test-reporter"
- ::CodeClimate::TestReporter.start
- configure_exclusions
- rescue LoadError
- # it's fine if CodeClimate isn't set up
- nil
- end
-
- def self.configure_exclusions
- SimpleCov.start do
- add_filter "/bin/"
- add_filter "/lib/bundler/man/"
- add_filter "/lib/bundler/vendor/"
- add_filter "/man/"
- add_filter "/pkg/"
- add_filter "/spec/"
- add_filter "/tmp/"
- end
- end
- end
-end
diff --git a/spec/bundler/support/command_execution.rb b/spec/bundler/support/command_execution.rb
index 556285ac52..cec531d6c3 100644
--- a/spec/bundler/support/command_execution.rb
+++ b/spec/bundler/support/command_execution.rb
@@ -27,14 +27,6 @@ module Spec
@stdboth ||= [stderr, stdout].join("\n").strip
end
- def bundler_err
- if Bundler::VERSION.start_with?("1.")
- stdout
- else
- stderr
- end
- end
-
def to_s_verbose
[
to_s,
diff --git a/spec/bundler/support/hax.rb b/spec/bundler/support/hax.rb
index b14e4a5943..202e8dcc32 100644
--- a/spec/bundler/support/hax.rb
+++ b/spec/bundler/support/hax.rb
@@ -21,6 +21,8 @@ module Gem
end
if ENV["BUNDLER_SPEC_VERSION"]
+ require "bundler/version"
+
module Bundler
remove_const(:VERSION) if const_defined?(:VERSION)
VERSION = ENV["BUNDLER_SPEC_VERSION"].dup
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 09e7419a98..478fe60822 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -45,13 +45,13 @@ module Spec
end
def err
- Bundler.feature_flag.error_on_stderr? ? last_command.stderr : last_command.stdout
+ last_command.stderr
end
MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/.freeze
def err_without_deprecations
- last_command.stderr.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "")
+ err.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "")
end
def deprecations
diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb
index f9efe32a38..5d1a6a7919 100644
--- a/spec/bundler/support/matchers.rb
+++ b/spec/bundler/support/matchers.rb
@@ -133,7 +133,7 @@ module Spec
rescue StandardError => e
next "#{name} is not installed:\n#{indent(e)}"
end
- actual_version, actual_platform = last_command.stdout.strip.split(/\s+/, 2)
+ actual_version, actual_platform = out.strip.split(/\s+/, 2)
unless Gem::Version.new(actual_version) == Gem::Version.new(version)
next "#{name} was expected to be at version #{version} but was #{actual_version}"
end
@@ -147,7 +147,7 @@ module Spec
rescue StandardError
next "#{name} does not have a source defined:\n#{indent(e)}"
end
- unless last_command.stdout.strip == source
+ unless out.strip == source
next "Expected #{name} (#{version}) to be installed from `#{source}`, was actually from `#{out}`"
end
end.compact
@@ -172,9 +172,9 @@ module Spec
rescue StandardError => e
next "checking for #{name} failed:\n#{e}"
end
- next if last_command.stdout == "WIN"
+ next if out == "WIN"
next "expected #{name} to not be installed, but it was" if version.nil?
- if Gem::Version.new(last_command.stdout) == Gem::Version.new(version)
+ if Gem::Version.new(out) == Gem::Version.new(version)
next "expected #{name} (#{version}) not to be installed, but it was"
end
end.compact
diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb
index 0a9e4a8cb6..caac7734bf 100644
--- a/spec/bundler/support/platforms.rb
+++ b/spec/bundler/support/platforms.rb
@@ -105,7 +105,7 @@ module Spec
end
def local_platforms
- if Bundler::VERSION.split(".").first.to_i > 2
+ if Bundler.feature_flag.specific_platform?
[local, specific_local_platform]
else
[local]
diff --git a/spec/bundler/update/git_spec.rb b/spec/bundler/update/git_spec.rb
index 4fe22269e2..bc230a3575 100644
--- a/spec/bundler/update/git_spec.rb
+++ b/spec/bundler/update/git_spec.rb
@@ -88,7 +88,7 @@ RSpec.describe "bundle update" do
gem "foo", "1.0", :git => "#{lib_path("foo_two")}"
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to include("Fetching #{lib_path}/foo_two")
expect(out).to include("Bundle complete!")
end
@@ -192,7 +192,7 @@ RSpec.describe "bundle update" do
lib_path("foo-1.0").join(".git").rmtree
bundle :update, :all => true
- expect(last_command.bundler_err).to include(lib_path("foo-1.0").to_s).
+ expect(err).to include(lib_path("foo-1.0").to_s).
and match(/Git error: command `git fetch.+has failed/)
end