1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Merge bundler master from upstream.

Pick from 8dd59e3ba97eb80a599f8149f31bf40773b69dc0
This commit is contained in:
Hiroshi SHIBATA 2019-06-01 12:49:40 +03:00
parent 6650899248
commit 8f37629519
155 changed files with 1366 additions and 1648 deletions

View file

@ -1,20 +1,20 @@
# frozen_string_literal: true # 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 "pathname"
require "rbconfig" require "rbconfig"
require "bundler/errors" require_relative "bundler/errors"
require "bundler/environment_preserver" require_relative "bundler/environment_preserver"
require "bundler/plugin" require_relative "bundler/plugin"
require "bundler/rubygems_ext" require_relative "bundler/rubygems_ext"
require "bundler/rubygems_integration" require_relative "bundler/rubygems_integration"
require "bundler/version" require_relative "bundler/version"
require "bundler/constants" require_relative "bundler/constants"
require "bundler/current_ruby" require_relative "bundler/current_ruby"
require "bundler/build_metadata" require_relative "bundler/build_metadata"
module Bundler module Bundler
environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS) environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS)
@ -22,43 +22,43 @@ module Bundler
ENV.replace(environment_preserver.backup) ENV.replace(environment_preserver.backup)
SUDO_MUTEX = Mutex.new SUDO_MUTEX = Mutex.new
autoload :Definition, "bundler/definition" autoload :Definition, File.expand_path("bundler/definition", __dir__)
autoload :Dependency, "bundler/dependency" autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
autoload :DepProxy, "bundler/dep_proxy" autoload :DepProxy, File.expand_path("bundler/dep_proxy", __dir__)
autoload :Deprecate, "bundler/deprecate" autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
autoload :Dsl, "bundler/dsl" autoload :Dsl, File.expand_path("bundler/dsl", __dir__)
autoload :EndpointSpecification, "bundler/endpoint_specification" autoload :EndpointSpecification, File.expand_path("bundler/endpoint_specification", __dir__)
autoload :Env, "bundler/env" autoload :Env, File.expand_path("bundler/env", __dir__)
autoload :Fetcher, "bundler/fetcher" autoload :Fetcher, File.expand_path("bundler/fetcher", __dir__)
autoload :FeatureFlag, "bundler/feature_flag" autoload :FeatureFlag, File.expand_path("bundler/feature_flag", __dir__)
autoload :GemHelper, "bundler/gem_helper" autoload :GemHelper, File.expand_path("bundler/gem_helper", __dir__)
autoload :GemHelpers, "bundler/gem_helpers" autoload :GemHelpers, File.expand_path("bundler/gem_helpers", __dir__)
autoload :GemRemoteFetcher, "bundler/gem_remote_fetcher" autoload :GemRemoteFetcher, File.expand_path("bundler/gem_remote_fetcher", __dir__)
autoload :GemVersionPromoter, "bundler/gem_version_promoter" autoload :GemVersionPromoter, File.expand_path("bundler/gem_version_promoter", __dir__)
autoload :Graph, "bundler/graph" autoload :Graph, File.expand_path("bundler/graph", __dir__)
autoload :Index, "bundler/index" autoload :Index, File.expand_path("bundler/index", __dir__)
autoload :Injector, "bundler/injector" autoload :Injector, File.expand_path("bundler/injector", __dir__)
autoload :Installer, "bundler/installer" autoload :Installer, File.expand_path("bundler/installer", __dir__)
autoload :LazySpecification, "bundler/lazy_specification" autoload :LazySpecification, File.expand_path("bundler/lazy_specification", __dir__)
autoload :LockfileParser, "bundler/lockfile_parser" autoload :LockfileParser, File.expand_path("bundler/lockfile_parser", __dir__)
autoload :MatchPlatform, "bundler/match_platform" autoload :MatchPlatform, File.expand_path("bundler/match_platform", __dir__)
autoload :ProcessLock, "bundler/process_lock" autoload :ProcessLock, File.expand_path("bundler/process_lock", __dir__)
autoload :RemoteSpecification, "bundler/remote_specification" autoload :RemoteSpecification, File.expand_path("bundler/remote_specification", __dir__)
autoload :Resolver, "bundler/resolver" autoload :Resolver, File.expand_path("bundler/resolver", __dir__)
autoload :Retry, "bundler/retry" autoload :Retry, File.expand_path("bundler/retry", __dir__)
autoload :RubyDsl, "bundler/ruby_dsl" autoload :RubyDsl, File.expand_path("bundler/ruby_dsl", __dir__)
autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer" autoload :RubyGemsGemInstaller, File.expand_path("bundler/rubygems_gem_installer", __dir__)
autoload :RubyVersion, "bundler/ruby_version" autoload :RubyVersion, File.expand_path("bundler/ruby_version", __dir__)
autoload :Runtime, "bundler/runtime" autoload :Runtime, File.expand_path("bundler/runtime", __dir__)
autoload :Settings, "bundler/settings" autoload :Settings, File.expand_path("bundler/settings", __dir__)
autoload :SharedHelpers, "bundler/shared_helpers" autoload :SharedHelpers, File.expand_path("bundler/shared_helpers", __dir__)
autoload :Source, "bundler/source" autoload :Source, File.expand_path("bundler/source", __dir__)
autoload :SourceList, "bundler/source_list" autoload :SourceList, File.expand_path("bundler/source_list", __dir__)
autoload :SpecSet, "bundler/spec_set" autoload :SpecSet, File.expand_path("bundler/spec_set", __dir__)
autoload :StubSpecification, "bundler/stub_specification" autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
autoload :UI, "bundler/ui" autoload :UI, File.expand_path("bundler/ui", __dir__)
autoload :URICredentialsFilter, "bundler/uri_credentials_filter" autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
autoload :VersionRanges, "bundler/version_ranges" autoload :VersionRanges, File.expand_path("bundler/version_ranges", __dir__)
class << self class << self
def configure def configure
@ -197,19 +197,19 @@ module Bundler
def user_bundle_path(dir = "home") def user_bundle_path(dir = "home")
env_var, fallback = case dir env_var, fallback = case dir
when "home" when "home"
["BUNDLE_USER_HOME", Pathname.new(user_home).join(".bundle")] ["BUNDLE_USER_HOME", proc { Pathname.new(user_home).join(".bundle") }]
when "cache" when "cache"
["BUNDLE_USER_CACHE", user_bundle_path.join("cache")] ["BUNDLE_USER_CACHE", proc { user_bundle_path.join("cache") }]
when "config" when "config"
["BUNDLE_USER_CONFIG", user_bundle_path.join("config")] ["BUNDLE_USER_CONFIG", proc { user_bundle_path.join("config") }]
when "plugin" when "plugin"
["BUNDLE_USER_PLUGIN", user_bundle_path.join("plugin")] ["BUNDLE_USER_PLUGIN", proc { user_bundle_path.join("plugin") }]
else else
raise BundlerError, "Unknown user path requested: #{dir}" raise BundlerError, "Unknown user path requested: #{dir}"
end end
# `fallback` will already be a Pathname, but Pathname.new() is # `fallback` will already be a Pathname, but Pathname.new() is
# idempotent so it's OK # idempotent so it's OK
Pathname.new(ENV.fetch(env_var, fallback)) Pathname.new(ENV.fetch(env_var, &fallback))
end end
def user_cache def user_cache

View file

@ -1,10 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
begin begin
require File.expand_path("../lib/bundler/version", __FILE__) require_relative "lib/bundler/version"
rescue LoadError rescue LoadError
# for Ruby core repository # for Ruby core repository
require File.expand_path("../version", __FILE__) require_relative "version"
end end
Gem::Specification.new do |s| Gem::Specification.new do |s|
@ -31,27 +31,23 @@ Gem::Specification.new do |s|
} }
end end
if s.version >= Gem::Version.new("2.a".dup)
s.required_ruby_version = ">= 2.3.0" s.required_ruby_version = ">= 2.3.0"
s.required_rubygems_version = ">= 2.5.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.add_development_dependency "automatiek", "~> 0.1.0" s.add_development_dependency "automatiek", "~> 0.1.0"
s.add_development_dependency "rake", "~> 12.0" s.add_development_dependency "rake", "~> 12.0"
s.add_development_dependency "ronn", "~> 0.7.3" s.add_development_dependency "ronn", "~> 0.7.3"
s.add_development_dependency "rspec", "~> 3.6" 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 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. # 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 # 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 # include the gemspec itself because warbler breaks w/o it
s.files += %w[bundler.gemspec] s.files += %w[bundler.gemspec]

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/shared_helpers" require_relative "shared_helpers"
Bundler::SharedHelpers.major_deprecation 2, Bundler::SharedHelpers.major_deprecation 2,
"The Bundler task for Capistrano. Please use http://github.com/capistrano/bundler" "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 # Add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
# Bundler will be activated after each new deployment. # Bundler will be activated after each new deployment.
require "bundler/deployment" require_relative "deployment"
require "capistrano/version" require "capistrano/version"
if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0") if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")

View file

@ -1,11 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler" require_relative "vendored_thor"
require "bundler/vendored_thor"
module Bundler module Bundler
class CLI < Thor class CLI < Thor
require "bundler/cli/common" require_relative "cli/common"
package_name "Bundler" package_name "Bundler"
@ -139,7 +138,7 @@ module Bundler
D D
method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile" method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
def init def init
require "bundler/cli/init" require_relative "cli/init"
Init.new(options.dup).run Init.new(options.dup).run
end 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?}" "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" map "c" => "check"
def check def check
require "bundler/cli/check" require_relative "cli/check"
Check.new(options).run Check.new(options).run
end end
@ -168,7 +167,7 @@ module Bundler
method_option "install", :type => :boolean, :banner => method_option "install", :type => :boolean, :banner =>
"Runs 'bundle install' after removing the gems from the Gemfile" "Runs 'bundle install' after removing the gems from the Gemfile"
def remove(*gems) def remove(*gems)
require "bundler/cli/remove" require_relative "cli/remove"
Remove.new(gems, options).run Remove.new(gems, options).run
end end
@ -230,7 +229,7 @@ module Bundler
remembered_flag_deprecation(option) remembered_flag_deprecation(option)
end end
require "bundler/cli/install" require_relative "cli/install"
Bundler.settings.temporary(:no_install => false) do Bundler.settings.temporary(:no_install => false) do
Install.new(options.dup).run Install.new(options.dup).run
end end
@ -276,7 +275,7 @@ module Bundler
"Update everything." "Update everything."
def update(*gems) def update(*gems)
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") 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 Bundler.settings.temporary(:no_install => false) do
Update.new(options, gems).run Update.new(options, gems).run
end end
@ -312,7 +311,7 @@ module Bundler
Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
end end
end end
require "bundler/cli/show" require_relative "cli/show"
Show.new(options, gem_name).run Show.new(options, gem_name).run
end end
end end
@ -323,7 +322,7 @@ module Bundler
method_option "without-group", :type => :string, :banner => "print all gems except from a group" 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" method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
def list def list
require "bundler/cli/list" require_relative "cli/list"
List.new(options).run List.new(options).run
end end
@ -332,7 +331,7 @@ module Bundler
desc "info GEM [OPTIONS]", "Show information for the given gem" desc "info GEM [OPTIONS]", "Show information for the given gem"
method_option "path", :type => :boolean, :banner => "Print full path to gem" method_option "path", :type => :boolean, :banner => "Print full path to gem"
def info(gem_name) def info(gem_name)
require "bundler/cli/info" require_relative "cli/info"
Info.new(options, gem_name).run Info.new(options, gem_name).run
end end
@ -353,7 +352,7 @@ module Bundler
method_option "all", :type => :boolean, :banner => method_option "all", :type => :boolean, :banner =>
"Install binstubs for all gems" "Install binstubs for all gems"
def binstubs(*gems) def binstubs(*gems)
require "bundler/cli/binstubs" require_relative "cli/binstubs"
Binstubs.new(options, gems).run Binstubs.new(options, gems).run
end end
@ -364,12 +363,14 @@ module Bundler
method_option "version", :aliases => "-v", :type => :string method_option "version", :aliases => "-v", :type => :string
method_option "group", :aliases => "-g", :type => :string method_option "group", :aliases => "-g", :type => :string
method_option "source", :aliases => "-s", :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 => method_option "skip-install", :type => :boolean, :banner =>
"Adds gem to the Gemfile but does not install it" "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 "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem" method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
def add(*gems) def add(*gems)
require "bundler/cli/add" require_relative "cli/add"
Add.new(options.dup, gems).run Add.new(options.dup, gems).run
end end
@ -405,7 +406,7 @@ module Bundler
method_option "only-explicit", :type => :boolean, :banner => method_option "only-explicit", :type => :boolean, :banner =>
"Only list gems specified in your Gemfile, not their dependencies" "Only list gems specified in your Gemfile, not their dependencies"
def outdated(*gems) def outdated(*gems)
require "bundler/cli/outdated" require_relative "cli/outdated"
Outdated.new(options, gems).run Outdated.new(options, gems).run
end 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 "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." method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
def cache def cache
require "bundler/cli/cache" require_relative "cli/cache"
Cache.new(options).run Cache.new(options).run
end end
end end
@ -448,7 +449,7 @@ module Bundler
bundle without having to download any additional gems. bundle without having to download any additional gems.
D D
def package def package
require "bundler/cli/package" require_relative "cli/package"
Package.new(options).run Package.new(options).run
end end
map %w[pack] => :package map %w[pack] => :package
@ -463,7 +464,7 @@ module Bundler
D D
map "e" => "exec" map "e" => "exec"
def exec(*args) def exec(*args)
require "bundler/cli/exec" require_relative "cli/exec"
Exec.new(options, args).run Exec.new(options, args).run
end end
@ -479,19 +480,19 @@ module Bundler
will show the current value, as well as any superceded values and will show the current value, as well as any superceded values and
where they were specified. where they were specified.
D D
require "bundler/cli/config" require_relative "cli/config"
subcommand "config", Config subcommand "config", Config
desc "open GEM", "Opens the source directory of the given bundled gem" desc "open GEM", "Opens the source directory of the given bundled gem"
def open(name) def open(name)
require "bundler/cli/open" require_relative "cli/open"
Open.new(options, name).run Open.new(options, name).run
end end
unless Bundler.feature_flag.bundler_3_mode? unless Bundler.feature_flag.bundler_3_mode?
desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded" desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
def console(group = nil) def console(group = nil)
require "bundler/cli/console" require_relative "cli/console"
Console.new(options, group).run Console.new(options, group).run
end end
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." method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
def viz def viz
SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-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 Viz.new(options.dup).run
end end
end end
@ -563,7 +564,7 @@ module Bundler
def gem_command.run(instance, args = []) def gem_command.run(instance, args = [])
arity = 1 # name arity = 1 # name
require "bundler/cli/gem" require_relative "cli/gem"
cmd_args = args + [instance] cmd_args = args + [instance]
cmd_args.unshift(instance.options) cmd_args.unshift(instance.options)
@ -591,7 +592,7 @@ module Bundler
method_option "force", :type => :boolean, :default => false, :banner => method_option "force", :type => :boolean, :default => false, :banner =>
"Forces clean even if --path is not set" "Forces clean even if --path is not set"
def clean def clean
require "bundler/cli/clean" require_relative "cli/clean"
Clean.new(options.dup).run Clean.new(options.dup).run
end end
@ -599,7 +600,7 @@ module Bundler
method_option "ruby", :type => :boolean, :default => false, :banner => method_option "ruby", :type => :boolean, :default => false, :banner =>
"only display ruby related platform information" "only display ruby related platform information"
def platform def platform
require "bundler/cli/platform" require_relative "cli/platform"
Platform.new(options).run Platform.new(options).run
end end
@ -610,7 +611,7 @@ module Bundler
"Install gem into a bundler group" "Install gem into a bundler group"
def inject(name, version) def inject(name, version)
SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command" 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 Inject.new(options.dup, name, version).run
end end
@ -642,7 +643,7 @@ module Bundler
method_option "conservative", :type => :boolean, :banner => method_option "conservative", :type => :boolean, :banner =>
"If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated" "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
def lock def lock
require "bundler/cli/lock" require_relative "cli/lock"
Lock.new(options).run Lock.new(options).run
end end
@ -662,13 +663,13 @@ module Bundler
method_option "quiet", :type => :boolean, :banner => method_option "quiet", :type => :boolean, :banner =>
"Only output warnings and errors." "Only output warnings and errors."
def doctor def doctor
require "bundler/cli/doctor" require_relative "cli/doctor"
Doctor.new(options).run Doctor.new(options).run
end end
desc "issue", "Learn how to report an issue in Bundler" desc "issue", "Learn how to report an issue in Bundler"
def issue def issue
require "bundler/cli/issue" require_relative "cli/issue"
Issue.new.run Issue.new.run
end end
@ -679,12 +680,12 @@ module Bundler
checkout --force`. checkout --force`.
D D
def pristine(*gems) def pristine(*gems)
require "bundler/cli/pristine" require_relative "cli/pristine"
Pristine.new(gems).run Pristine.new(gems).run
end end
if Bundler.feature_flag.plugins? if Bundler.feature_flag.plugins?
require "bundler/cli/plugin" require_relative "cli/plugin"
desc "plugin", "Manage the bundler plugins" desc "plugin", "Manage the bundler plugins"
subcommand "plugin", Plugin subcommand "plugin", Plugin
end end

View file

@ -2,34 +2,45 @@
module Bundler module Bundler
class CLI::Add class CLI::Add
attr_reader :gems, :options, :version
def initialize(options, gems) def initialize(options, gems)
@gems = gems @gems = gems
@options = options @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 end
def run def run
raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if @options[:strict] && @options[:optimistic] validate_options!
inject_dependencies
perform_bundle_install unless options["skip-install"]
end
private
def perform_bundle_install
Installer.install(Bundler.root, Bundler.definition)
end
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])
end
def validate_options!
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 error when no gems are specified
raise InvalidOption, "Please specify gems to add." if @gems.empty? raise InvalidOption, "Please specify gems to add." if gems.empty?
version = @options[:version].nil? ? nil : @options[:version].split(",").map(&:strip) version.to_a.each do |v|
unless version.nil?
version.each do |v|
raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
end end
end end
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])
Installer.install(Bundler.root, Bundler.definition) unless @options["skip-install"]
end
end end
end end

View file

@ -14,17 +14,18 @@ module Bundler
Bundler.ui.info msg Bundler.ui.info msg
end end
def self.output_without_groups_message def self.output_without_groups_message(command)
return if Bundler.settings[:without].empty? return if Bundler.settings[:without].empty?
Bundler.ui.confirm without_groups_message Bundler.ui.confirm without_groups_message(command)
end end
def self.without_groups_message def self.without_groups_message(command)
command_in_past_tense = command == :install ? "installed" : "updated"
groups = Bundler.settings[:without] groups = Bundler.settings[:without]
group_list = [groups[0...-1].join(", "), groups[-1..-1]]. group_list = [groups[0...-1].join(", "), groups[-1..-1]].
reject {|s| s.to_s.empty? }.join(" and ") reject {|s| s.to_s.empty? }.join(" and ")
group_str = groups.size == 1 ? "group" : "groups" 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 end
def self.select_spec(name, regex_match = nil) def self.select_spec(name, regex_match = nil)
@ -59,7 +60,7 @@ module Bundler
end end
def self.gem_not_found_message(missing_gem_name, alternatives) 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}'." message = "Could not find gem '#{missing_gem_name}'."
alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a } alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a }
suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name) suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)

View file

@ -56,7 +56,7 @@ module Bundler
end end
def check! def check!
require "bundler/cli/check" require_relative "check"
Bundler::CLI::Check.new({}).run Bundler::CLI::Check.new({}).run
end end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/current_ruby" require_relative "../current_ruby"
module Bundler module Bundler
class CLI::Exec class CLI::Exec
@ -27,12 +27,7 @@ module Bundler
if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path) if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path)
return kernel_load(bin_path, *args) return kernel_load(bin_path, *args)
end end
# First, try to exec directly to something in PATH
if Bundler.current_ruby.jruby_18?
kernel_exec(bin_path, *args) kernel_exec(bin_path, *args)
else
kernel_exec([bin_path, cmd], *args)
end
else else
# exec using the given command # exec using the given command
kernel_exec(cmd, *args) kernel_exec(cmd, *args)
@ -69,7 +64,7 @@ module Bundler
Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle) Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle)
ui = Bundler.ui ui = Bundler.ui
Bundler.ui = nil Bundler.ui = nil
require "bundler/setup" require_relative "../setup"
TRAPPED_SIGNALS.each {|s| trap(s, "DEFAULT") } TRAPPED_SIGNALS.each {|s| trap(s, "DEFAULT") }
Kernel.load(file) Kernel.load(file)
rescue SystemExit, SignalException rescue SystemExit, SignalException

View file

@ -66,7 +66,7 @@ module Bundler
Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle? 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.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? if Bundler.use_system_gems?
Bundler.ui.confirm "Use `bundle info [gemname]` to see where a bundled gem is installed." Bundler.ui.confirm "Use `bundle info [gemname]` to see where a bundled gem is installed."
@ -80,7 +80,7 @@ module Bundler
warn_ambiguous_gems warn_ambiguous_gems
if CLI::Common.clean_after_install? if CLI::Common.clean_after_install?
require "bundler/cli/clean" require_relative "clean"
Bundler::CLI::Clean.new(options).run Bundler::CLI::Clean.new(options).run
end end
rescue GemNotFound, VersionConflict => e rescue GemNotFound, VersionConflict => e

View file

@ -33,7 +33,7 @@ module Bundler
end end
def doctor def doctor
require "bundler/cli/doctor" require_relative "doctor"
Bundler::CLI::Doctor.new({}).run Bundler::CLI::Doctor.new({}).run
end end
end end

View file

@ -133,7 +133,7 @@ module Bundler
unless options[:parseable] unless options[:parseable]
if groups if groups
Bundler.ui.info "===== Group #{groups} =====" Bundler.ui.info "===== #{groups_text("Group", groups)} ====="
else else
Bundler.ui.info "===== Without group =====" Bundler.ui.info "===== Without group ====="
end end
@ -167,6 +167,10 @@ module Bundler
private private
def groups_text(group_text, groups)
"#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\""
end
def retrieve_active_spec(strict, definition, current_spec) def retrieve_active_spec(strict, definition, current_spec)
if strict if strict
active_spec = definition.find_resolved_spec(current_spec) active_spec = definition.find_resolved_spec(current_spec)
@ -212,7 +216,7 @@ module Bundler
elsif options_include_groups || !groups elsif options_include_groups || !groups
" * #{spec_outdated_info}" " * #{spec_outdated_info}"
else else
" * #{spec_outdated_info} in groups \"#{groups}\"" " * #{spec_outdated_info} in #{groups_text("group", groups)}"
end end
Bundler.ui.info output_message.rstrip Bundler.ui.info output_message.rstrip

View file

@ -25,7 +25,7 @@ module Bundler
private private
def install def install
require "bundler/cli/install" require_relative "install"
options = self.options.dup options = self.options.dup
if Bundler.settings[:cache_all_platforms] if Bundler.settings[:cache_all_platforms]
options["local"] = false options["local"] = false

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/vendored_thor" require_relative "../vendored_thor"
module Bundler module Bundler
class CLI::Plugin < Thor class CLI::Plugin < Thor
desc "install PLUGINS", "Install the plugin from the source" desc "install PLUGINS", "Install the plugin from the source"

View file

@ -58,24 +58,44 @@ module Bundler
Bundler.settings.set_command_option_if_given :jobs, opts["jobs"] Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
Bundler.definition.validate_runtime! 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 installer = Installer.install Bundler.root, Bundler.definition, opts
Bundler.load.cache if Bundler.app_cache.exist? Bundler.load.cache if Bundler.app_cache.exist?
if CLI::Common.clean_after_install? if CLI::Common.clean_after_install?
require "bundler/cli/clean" require_relative "clean"
Bundler::CLI::Clean.new(options).run Bundler::CLI::Clean.new(options).run
end end
if locked_gems = Bundler.definition.locked_gems if locked_gems
gems.each do |name| gems.each do |name|
locked_version = locked_gems.specs.find {|s| s.name == name } locked_info = previous_locked_info[name]
locked_version &&= locked_version.version next unless locked_info
next unless locked_version
new_version = Bundler.definition.specs[name].first locked_spec = locked_info[:spec]
new_version &&= new_version.version new_spec = Bundler.definition.specs[name].first
if !new_version unless new_spec
Bundler.ui.warn "Bundler attempted to update #{name} but it was removed from the bundle" if Bundler.rubygems.platforms.none? {|p| locked_spec.match_platform(p) }
elsif new_version < locked_version 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}" Bundler.ui.warn "Note: #{name} version regressed from #{locked_version} to #{new_version}"
elsif new_version == locked_version elsif new_version == locked_version
Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same" Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same"
@ -84,7 +104,7 @@ module Bundler
end end
Bundler.ui.confirm "Bundle updated!" 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 Bundler::CLI::Common.output_post_install_messages installer.post_install_messages
end end
end end

View file

@ -13,8 +13,8 @@ module Bundler
class Error < StandardError; end class Error < StandardError; end
require "bundler/compact_index_client/cache" require_relative "compact_index_client/cache"
require "bundler/compact_index_client/updater" require_relative "compact_index_client/updater"
attr_reader :directory attr_reader :directory

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/vendored_fileutils" require_relative "../vendored_fileutils"
require "stringio" require "stringio"
require "zlib" require "zlib"

View file

@ -1,6 +1,6 @@
# frozen_string_literal: false # frozen_string_literal: false
require "bundler/version" require_relative "version"
if Bundler::VERSION.split(".").first.to_i >= 2 if Bundler::VERSION.split(".").first.to_i >= 2
if Gem::Version.new(Object::RUBY_VERSION.dup) < Gem::Version.new("2.3") if Gem::Version.new(Object::RUBY_VERSION.dup) < Gem::Version.new("2.3")

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/lockfile_parser" require_relative "lockfile_parser"
require "set" require "set"
module Bundler module Bundler
@ -385,7 +385,7 @@ module Bundler
end end
def to_lock def to_lock
require "bundler/lockfile_generator" require_relative "lockfile_generator"
LockfileGenerator.generate(self) LockfileGenerator.generate(self)
end end
@ -782,7 +782,7 @@ module Bundler
# Path sources have special logic # Path sources have special logic
if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec) if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
other_sources_specs = begin new_specs = begin
s.source.specs s.source.specs
rescue PathError, GitError rescue PathError, GitError
# if we won't need the source (according to the lockfile), # if we won't need the source (according to the lockfile),
@ -794,16 +794,18 @@ module Bundler
raise raise
end 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 # If the spec is no longer in the path source, unlock it. This
# commonly happens if the version changed in the gemspec # commonly happens if the version changed in the gemspec
next unless other next unless new_spec
deps2 = other.dependencies.select {|d| d.type != :development } new_runtime_deps = new_spec.dependencies.select {|d| d.type != :development }
runtime_dependencies = s.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, unlock it # If the dependencies of the path source have changed and locked spec can't satisfy new dependencies, unlock it
next unless runtime_dependencies.sort == deps2.sort 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 end
converged << s converged << s

View file

@ -1,13 +1,13 @@
# frozen_string_literal: true # frozen_string_literal: true
require "rubygems/dependency" require "rubygems/dependency"
require "bundler/shared_helpers" require_relative "shared_helpers"
require "bundler/rubygems_ext" require_relative "rubygems_ext"
module Bundler module Bundler
class Dependency < Gem::Dependency class Dependency < Gem::Dependency
attr_reader :autorequire attr_reader :autorequire
attr_reader :groups, :platforms, :gemfile attr_reader :groups, :platforms, :gemfile, :git, :branch
PLATFORM_MAP = { PLATFORM_MAP = {
:ruby => Gem::Platform::RUBY, :ruby => Gem::Platform::RUBY,
@ -84,6 +84,8 @@ module Bundler
@autorequire = nil @autorequire = nil
@groups = Array(options["group"] || :default).map(&:to_sym) @groups = Array(options["group"] || :default).map(&:to_sym)
@source = options["source"] @source = options["source"]
@git = options["git"]
@branch = options["branch"]
@platforms = Array(options["platforms"]) @platforms = Array(options["platforms"])
@env = options["env"] @env = options["env"]
@should_include = options.fetch("should_include", true) @should_include = options.fetch("should_include", true)

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/shared_helpers" require_relative "shared_helpers"
Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \ Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \
"Capistrano, but Capistrano provides its own integration with " \ "Capistrano, but Capistrano provides its own integration with " \
"Bundler via the capistrano-bundler gem. Use it instead." "Bundler via the capistrano-bundler gem. Use it instead."

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/dependency" require_relative "dependency"
require "bundler/ruby_dsl" require_relative "ruby_dsl"
module Bundler module Bundler
class Dsl class Dsl
@ -291,12 +291,7 @@ module Bundler
"https://github.com/#{repo_name}.git" "https://github.com/#{repo_name}.git"
RUBY RUBY
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
if Bundler.feature_flag.github_https?
"https://github.com/#{repo_name}.git" "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
end end
git_source(:gist) do |repo_name| git_source(:gist) do |repo_name|

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/rubygems_integration" require_relative "rubygems_integration"
require "bundler/source/git/git_proxy" require_relative "source/git/git_proxy"
module Bundler module Bundler
class Env class Env
@ -100,8 +100,9 @@ module Bundler
out << [" Full Path", Gem.ruby] out << [" Full Path", Gem.ruby]
out << [" Config Dir", Pathname.new(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE).dirname] out << [" Config Dir", Pathname.new(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE).dirname]
out << ["RubyGems", Gem::VERSION] out << ["RubyGems", Gem::VERSION]
out << [" Gem Home", ENV.fetch("GEM_HOME") { Gem.dir }] out << [" Gem Home", Gem.dir]
out << [" Gem Path", ENV.fetch("GEM_PATH") { Gem.path.join(File::PATH_SEPARATOR) }] out << [" Gem Path", Gem.path.join(File::PATH_SEPARATOR)]
out << [" User Home", Gem.user_home]
out << [" User Path", Gem.user_dir] out << [" User Path", Gem.user_dir]
out << [" Bin Dir", Gem.bindir] out << [" Bin Dir", Gem.bindir]
if defined?(OpenSSL) if defined?(OpenSSL)

View file

@ -36,16 +36,14 @@ module Bundler
settings_flag(:default_install_uses_path) { bundler_3_mode? } settings_flag(:default_install_uses_path) { bundler_3_mode? }
settings_flag(:deployment_means_frozen) { bundler_3_mode? } settings_flag(:deployment_means_frozen) { bundler_3_mode? }
settings_flag(:disable_multisource) { 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(: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(:global_gem_cache) { bundler_3_mode? }
settings_flag(:only_update_to_newer_versions) { bundler_3_mode? } settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
settings_flag(:path_relative_to_cwd) { bundler_3_mode? } settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") } settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:print_only_version_number) { bundler_3_mode? } settings_flag(:print_only_version_number) { bundler_3_mode? }
settings_flag(:setup_makes_kernel_gem_public) { !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(:specific_platform) { bundler_3_mode? }
settings_flag(:suppress_install_using_messages) { bundler_3_mode? } settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
settings_flag(:unlock_source_unlocks_spec) { !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_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
settings_method(:github_https?, "github.https") { bundler_2_mode? }
def initialize(bundler_version) def initialize(bundler_version)
@bundler_version = Gem::Version.create(bundler_version) @bundler_version = Gem::Version.create(bundler_version)
end end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/vendored_persistent" require_relative "vendored_persistent"
require "cgi" require "cgi"
require "securerandom" require "securerandom"
require "zlib" require "zlib"
@ -9,10 +9,10 @@ require "rubygems/request"
module Bundler module Bundler
# Handles all the fetching with the rubygems server # Handles all the fetching with the rubygems server
class Fetcher class Fetcher
autoload :CompactIndex, "bundler/fetcher/compact_index" autoload :CompactIndex, File.expand_path("fetcher/compact_index", __dir__)
autoload :Downloader, "bundler/fetcher/downloader" autoload :Downloader, File.expand_path("fetcher/downloader", __dir__)
autoload :Dependency, "bundler/fetcher/dependency" autoload :Dependency, File.expand_path("fetcher/dependency", __dir__)
autoload :Index, "bundler/fetcher/index" autoload :Index, File.expand_path("fetcher/index", __dir__)
# This error is raised when it looks like the network is down # This error is raised when it looks like the network is down
class NetworkDownError < HTTPError; end class NetworkDownError < HTTPError; end

View file

@ -1,10 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/fetcher/base" require_relative "base"
require "bundler/worker" require_relative "../worker"
module Bundler module Bundler
autoload :CompactIndexClient, "bundler/compact_index_client" autoload :CompactIndexClient, File.expand_path("../compact_index_client", __dir__)
class Fetcher class Fetcher
class CompactIndex < Base class CompactIndex < Base

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/fetcher/base" require_relative "base"
require "cgi" require "cgi"
module Bundler module Bundler

View file

@ -37,6 +37,7 @@ module Bundler
when Net::HTTPTooManyRequests when Net::HTTPTooManyRequests
raise TooManyRequestsError, response.body raise TooManyRequestsError, response.body
when Net::HTTPUnauthorized when Net::HTTPUnauthorized
raise BadAuthenticationError, uri.host if uri.userinfo
raise AuthenticationRequiredError, uri.host raise AuthenticationRequiredError, uri.host
when Net::HTTPNotFound when Net::HTTPNotFound
raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}" raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}"

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/fetcher/base" require_relative "base"
require "rubygems/remote_fetcher" require "rubygems/remote_fetcher"
module Bundler module Bundler
@ -13,6 +13,7 @@ module Bundler
when /certificate verify failed/ when /certificate verify failed/
raise CertificateFailureError.new(display_uri) raise CertificateFailureError.new(display_uri)
when /401/ when /401/
raise BadAuthenticationError, remote_uri if remote_uri.userinfo
raise AuthenticationRequiredError, remote_uri raise AuthenticationRequiredError, remote_uri
when /403/ when /403/
raise BadAuthenticationError, remote_uri if remote_uri.userinfo raise BadAuthenticationError, remote_uri if remote_uri.userinfo

View file

@ -1,11 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
require "cgi" require "cgi"
require "bundler/vendored_thor" require_relative "vendored_thor"
module Bundler module Bundler
module FriendlyErrors module FriendlyErrors
module_function module_function # rubocop:disable Layout/AccessModifierIndentation
def log_error(error) def log_error(error)
case error case error

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/vendored_thor" unless defined?(Thor) require_relative "vendored_thor" unless defined?(Thor)
require "bundler" require_relative "../bundler"
require "shellwords" require "shellwords"
module Bundler module Bundler

View file

@ -3,5 +3,5 @@
require "rake/clean" require "rake/clean"
CLOBBER.include "pkg" CLOBBER.include "pkg"
require "bundler/gem_helper" require_relative "gem_helper"
Bundler::GemHelper.install_tasks Bundler::GemHelper.install_tasks

View file

@ -81,8 +81,8 @@ module Bundler
sort_dep_specs(spec_groups, locked_spec) sort_dep_specs(spec_groups, locked_spec)
end.tap do |specs| end.tap do |specs|
if DEBUG if DEBUG
STDERR.puts before_result warn before_result
STDERR.puts " after sort_versions: #{debug_format_result(dep, specs).inspect}" warn " after sort_versions: #{debug_format_result(dep, specs).inspect}"
end end
end end
end end

View file

@ -111,8 +111,10 @@ module Bundler
end end
source = ", :source => \"#{d.source}\"" unless d.source.nil? 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.join("\n")
end end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/compatibility_guard" require_relative "compatibility_guard"
# Allows for declaring a Gemfile inline in a ruby script, optionally installing # Allows for declaring a Gemfile inline in a ruby script, optionally installing
# any gems that aren't already installed on the user's system. # 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" # puts Pod::VERSION # => "0.34.4"
# #
def gemfile(install = false, options = {}, &gemfile) def gemfile(install = false, options = {}, &gemfile)
require "bundler" require_relative "../bundler"
opts = options.dup opts = options.dup
ui = opts.delete(:ui) { Bundler::UI::Shell.new } ui = opts.delete(:ui) { Bundler::UI::Shell.new }
@ -49,6 +49,7 @@ def gemfile(install = false, options = {}, &gemfile)
builder = Bundler::Dsl.new builder = Bundler::Dsl.new
builder.instance_eval(&gemfile) builder.instance_eval(&gemfile)
Bundler.settings.temporary(:frozen => false) do
definition = builder.to_definition(nil, true) definition = builder.to_definition(nil, true)
def definition.lock(*); end def definition.lock(*); end
definition.validate_runtime! definition.validate_runtime!
@ -59,7 +60,7 @@ def gemfile(install = false, options = {}, &gemfile)
Bundler.ui = ui if install Bundler.ui = ui if install
if install || missing_specs.call if install || missing_specs.call
Bundler.settings.temporary(:inline => true) do Bundler.settings.temporary(:inline => true, :disable_platform_warnings => true) do
installer = Bundler::Installer.install(Bundler.root, definition, :system => true) installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
installer.post_install_messages.each do |name, message| installer.post_install_messages.each do |name, message|
Bundler.ui.info "Post-install message from #{name}:\n#{message}" Bundler.ui.info "Post-install message from #{name}:\n#{message}"
@ -69,6 +70,7 @@ def gemfile(install = false, options = {}, &gemfile)
runtime = Bundler::Runtime.new(nil, definition) runtime = Bundler::Runtime.new(nil, definition)
runtime.setup.require runtime.setup.require
end
ensure ensure
bundler_module = class << Bundler; self; end bundler_module = class << Bundler; self; end
bundler_module.send(:define_method, :root, old_root) if old_root bundler_module.send(:define_method, :root, old_root) if old_root

View file

@ -2,10 +2,10 @@
require "erb" require "erb"
require "rubygems/dependency_installer" require "rubygems/dependency_installer"
require "bundler/worker" require_relative "worker"
require "bundler/installer/parallel_installer" require_relative "installer/parallel_installer"
require "bundler/installer/standalone" require_relative "installer/standalone"
require "bundler/installer/gem_installer" require_relative "installer/gem_installer"
module Bundler module Bundler
class Installer class Installer

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/worker" require_relative "../worker"
require "bundler/installer/gem_installer" require_relative "gem_installer"
module Bundler module Bundler
class ParallelInstaller class ParallelInstaller

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "uri" require "uri"
require "bundler/match_platform" require_relative "match_platform"
module Bundler module Bundler
class LazySpecification class LazySpecification

View file

@ -101,18 +101,12 @@ module Bundler
return unless bundler_version return unless bundler_version
prerelease_text = bundler_version.prerelease? ? " --pre" : "" prerelease_text = bundler_version.prerelease? ? " --pre" : ""
current_version = Gem::Version.create(Bundler::VERSION) current_version = Gem::Version.create(Bundler::VERSION)
case current_version.segments.first <=> bundler_version.segments.first return unless current_version < bundler_version
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 " \ 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 " \ "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 " \ "upgrade to the version that created the lockfile by running `gem install " \
"bundler:#{bundler_version}#{prerelease_text}`.\n" "bundler:#{bundler_version}#{prerelease_text}`.\n"
end end
end
end
private private

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/gem_helpers" require_relative "gem_helpers"
module Bundler module Bundler
module MatchPlatform module MatchPlatform

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/plugin/api" require_relative "plugin/api"
module Bundler module Bundler
module Plugin module Plugin
@ -256,7 +256,7 @@ module Bundler
@hooks_by_event = Hash.new {|h, k| h[k] = [] } @hooks_by_event = Hash.new {|h, k| h[k] = [] }
load_paths = spec.load_paths 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 path = Pathname.new spec.full_gem_path
begin begin
@ -288,7 +288,7 @@ module Bundler
# done to avoid conflicts # done to avoid conflicts
path = index.plugin_path(name) 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) load path.join(PLUGIN_FILE_NAME)
@ -298,17 +298,8 @@ module Bundler
raise raise
end 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 class << self
private :load_plugin, :register_plugin, :save_plugins, :validate_plugin!, private :load_plugin, :register_plugin, :save_plugins, :validate_plugin!
:add_to_load_path
end end
end end
end end

View file

@ -23,7 +23,7 @@ module Bundler
# and hooks). # and hooks).
module Plugin module Plugin
class API 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. # The plugins should declare that they handle a command through this helper.
# #

View file

@ -139,7 +139,7 @@ module Bundler
data = index_f.read data = index_f.read
require "bundler/yaml_serializer" require_relative "../yaml_serializer"
index = YAMLSerializer.load(data) index = YAMLSerializer.load(data)
@commands.merge!(index["commands"]) @commands.merge!(index["commands"])
@ -162,7 +162,7 @@ module Bundler
"sources" => @sources, "sources" => @sources,
} }
require "bundler/yaml_serializer" require_relative "../yaml_serializer"
SharedHelpers.filesystem_access(index_file) do |index_f| SharedHelpers.filesystem_access(index_file) do |index_f|
FileUtils.mkdir_p(index_f.dirname) FileUtils.mkdir_p(index_f.dirname)
File.open(index_f, "w") {|f| f.puts YAMLSerializer.dump(index) } File.open(index_f, "w") {|f| f.puts YAMLSerializer.dump(index) }

View file

@ -8,8 +8,8 @@ module Bundler
# are heavily dependent on the Gemfile. # are heavily dependent on the Gemfile.
module Plugin module Plugin
class Installer class Installer
autoload :Rubygems, "bundler/plugin/installer/rubygems" autoload :Rubygems, File.expand_path("installer/rubygems", __dir__)
autoload :Git, "bundler/plugin/installer/git" autoload :Git, File.expand_path("installer/git", __dir__)
def install(names, options) def install(names, options)
check_sources_consistency!(options) check_sources_consistency!(options)

View file

@ -27,7 +27,7 @@ module Bundler
end end
end end
require "bundler/deprecate" require_relative "deprecate"
begin begin
Bundler::Deprecate.skip_during do Bundler::Deprecate.skip_during do
require "rubygems/safe_yaml" require "rubygems/safe_yaml"

View file

@ -2,8 +2,8 @@
module Bundler module Bundler
class Resolver class Resolver
require "bundler/vendored_molinillo" require_relative "vendored_molinillo"
require "bundler/resolver/spec_group" require_relative "resolver/spec_group"
# Figures out the best possible configuration of gems that satisfies # Figures out the best possible configuration of gems that satisfies
# the list of passed dependencies and any child dependencies without # the list of passed dependencies and any child dependencies without
@ -75,7 +75,7 @@ module Bundler
return unless debug? return unless debug?
debug_info = yield debug_info = yield
debug_info = debug_info.inspect unless debug_info.is_a?(String) 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 end
def debug? def debug?

View file

@ -4,40 +4,25 @@ require "pathname"
require "rubygems/specification" require "rubygems/specification"
begin # Possible use in Gem::Specification#source below and require
# Possible use in Gem::Specification#source below and require # shouldn't be deferred.
# shouldn't be deferred. require "rubygems/source"
require "rubygems/source"
rescue LoadError
# Not available before RubyGems 2.0.0, ignore
nil
end
require "bundler/match_platform" require_relative "match_platform"
module Gem module Gem
@loaded_stacks = Hash.new {|h, k| h[k] = [] }
class Specification class Specification
attr_accessor :remote, :location, :relative_loaded_from attr_accessor :remote, :location, :relative_loaded_from
if instance_methods(false).include?(:source)
remove_method :source remove_method :source
attr_writer :source attr_writer :source
def source def source
(defined?(@source) && @source) || Gem::Source::Installed.new (defined?(@source) && @source) || Gem::Source::Installed.new
end end
else
# rubocop:disable Lint/DuplicateMethods
attr_accessor :source
# rubocop:enable Lint/DuplicateMethods
end
alias_method :rg_full_gem_path, :full_gem_path alias_method :rg_full_gem_path, :full_gem_path
alias_method :rg_loaded_from, :loaded_from alias_method :rg_loaded_from, :loaded_from
attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
def full_gem_path def full_gem_path
# this cannot check source.is_a?(Bundler::Plugin::API::Source) # this cannot check source.is_a?(Bundler::Plugin::API::Source)
# because that _could_ trip the autoload, and if there are unresolved # because that _could_ trip the autoload, and if there are unresolved
@ -59,15 +44,7 @@ module Gem
end end
def load_paths def load_paths
return full_require_paths if respond_to?(:full_require_paths) 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
end end
if method_defined?(:extension_dir) if method_defined?(:extension_dir)
@ -151,32 +128,6 @@ module Gem
end end
out out
end 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 end
class Platform class Platform

View file

@ -1,12 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
require "monitor"
module Bundler module Bundler
class RubygemsIntegration class RubygemsIntegration
if defined?(Gem::Ext::Builder::CHDIR_MONITOR) if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
else else
require "monitor"
EXT_LOCK = Monitor.new EXT_LOCK = Monitor.new
end end
@ -20,6 +20,7 @@ module Bundler
def initialize def initialize
@replaced_methods = {} @replaced_methods = {}
backport_ext_builder_monitor
end end
def version def version
@ -38,14 +39,22 @@ module Bundler
Gem::Command.build_args = args Gem::Command.build_args = args
end end
def load_path_insert_index
Gem.load_path_insert_index
end
def loaded_specs(name) def loaded_specs(name)
Gem.loaded_specs[name] Gem.loaded_specs[name]
end 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) def mark_loaded(spec)
if spec.respond_to?(:activated=) if spec.respond_to?(:activated=)
current = Gem.loaded_specs[spec.name] current = Gem.loaded_specs[spec.name]
@ -110,7 +119,7 @@ module Bundler
end end
def configuration def configuration
require "bundler/psyched_yaml" require_relative "psyched_yaml"
Gem.configuration Gem.configuration
rescue Gem::SystemExitException, LoadError => e rescue Gem::SystemExitException, LoadError => e
Bundler.ui.error "#{e.class}: #{e.message}" Bundler.ui.error "#{e.class}: #{e.message}"
@ -198,10 +207,6 @@ module Bundler
Gem::ConfigMap Gem::ConfigMap
end end
def repository_subdirectories
%w[cache doc gems specifications]
end
def clear_paths def clear_paths
Gem.clear_paths Gem.clear_paths
end end
@ -210,26 +215,14 @@ module Bundler
Gem.bin_path(gem, bin, ver) Gem.bin_path(gem, bin, ver)
end end
def path_separator
File::PATH_SEPARATOR
end
def preserve_paths def preserve_paths
# this is a no-op outside of RubyGems 1.8 # this is a no-op outside of RubyGems 1.8
yield yield
end end
def loaded_gem_paths 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 = Gem.loaded_specs.map {|_, s| s.full_require_paths }
loaded_gem_paths.flatten loaded_gem_paths.flatten
else
$LOAD_PATH.select do |p|
Bundler.rubygems.gem_path.any? {|gp| p =~ /^#{Regexp.escape(gp)}/ }
end
end
end end
def load_plugins def load_plugins
@ -248,36 +241,12 @@ module Bundler
EXT_LOCK EXT_LOCK
end 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 def fetch_prerelease_specs
fetch_specs(false, true) fetch_specs(false, true)
rescue Gem::RemoteFetcher::FetchError rescue Gem::RemoteFetcher::FetchError
{} # if we can't download them, there aren't any {} # if we can't download them, there aren't any
end 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) def with_build_args(args)
ext_lock.synchronize do ext_lock.synchronize do
old_args = build_args old_args = build_args
@ -290,18 +259,9 @@ module Bundler
end end
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) def spec_from_gem(path, policy = nil)
require "rubygems/security" require "rubygems/security"
require "bundler/psyched_yaml" require_relative "psyched_yaml"
gem_from_path(path, security_policies[policy]).spec gem_from_path(path, security_policies[policy]).spec
rescue Gem::Package::FormatError rescue Gem::Package::FormatError
raise GemspecError, "Could not read gem at #{path}. It may be corrupted." raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
@ -317,23 +277,10 @@ module Bundler
end end
end end
def build(spec, skip_validation = false)
require "rubygems/builder"
Gem::Builder.new(spec).build
end
def build_gem(gem_dir, spec) def build_gem(gem_dir, spec)
build(spec) build(spec)
end 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 def security_policy_keys
%w[High Medium Low AlmostNo No].map {|level| "#{level}Security" } %w[High Medium Low AlmostNo No].map {|level| "#{level}Security" }
end end
@ -357,12 +304,17 @@ module Bundler
end end
end end
# RubyGems-generated binstubs call Kernel#gem
def binstubs_call_gem? def binstubs_call_gem?
true !provides?(">= 2.5.2")
end 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? def stubs_provide_full_functionality?
false provides?(">= 2.5.2")
end end
def replace_gem(specs, specs_by_name) def replace_gem(specs, specs_by_name)
@ -411,26 +363,6 @@ module Bundler
end end
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 # Used to make bin stubs that are not created by bundler work
# under bundler. The new Gem.bin_path only considers gems in # under bundler. The new Gem.bin_path only considers gems in
# +specs+ # +specs+
@ -531,25 +463,6 @@ module Bundler
Gem.clear_paths Gem.clear_paths
end 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 # This backports base_dir which replaces installation path
# RubyGems 1.8+ # RubyGems 1.8+
def backport_base_dir def backport_base_dir
@ -622,117 +535,6 @@ module Bundler
end end
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)
# 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
end
def all_specs
Gem.source_index.gems.values
end
def find_name(name)
Gem.source_index.find_name(name)
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 post_reset_hooks
[]
end
def reset
end
end
# RubyGems versions 1.3.6 and 1.3.7
class Ancient < Legacy
def initialize
super
backport_segment_generation
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
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
stub_source_index(specs)
end
def all_specs
Gem::Specification.to_a
end
def find_name(name)
Gem::Specification.find_all_by_name name
end
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
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)
end
end
# RubyGems 2.0
class Future < RubygemsIntegration
def stub_rubygems(specs) def stub_rubygems(specs)
Gem::Specification.all = specs Gem::Specification.all = specs
@ -745,14 +547,6 @@ module Bundler
end end
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) def fetch_specs(source, remote, name)
path = source + "#{name}.#{Gem.marshal_version}.gz" path = source + "#{name}.#{Gem.marshal_version}.gz"
fetcher = gem_remote_fetcher fetcher = gem_remote_fetcher
@ -812,17 +606,9 @@ module Bundler
def path_separator def path_separator
Gem.path_separator Gem.path_separator
end end
end
# RubyGems 2.1.0
class MoreFuture < Future
def initialize
super
backport_ext_builder_monitor
end
def all_specs def all_specs
require "bundler/remote_specification" require_relative "remote_specification"
Gem::Specification.stubs.map do |stub| Gem::Specification.stubs.map do |stub|
StubSpecification.from_stub(stub) StubSpecification.from_stub(stub)
end end
@ -847,17 +633,9 @@ module Bundler
end end
end end
if Gem::Specification.respond_to?(:stubs_for)
def find_name(name) def find_name(name)
Gem::Specification.stubs_for(name).map(&:to_spec) Gem::Specification.stubs_for(name).map(&:to_spec)
end end
else
def find_name(name)
Gem::Specification.stubs.find_all do |spec|
spec.name == name
end.map(&:to_spec)
end
end
if Gem::Specification.respond_to?(:default_stubs) if Gem::Specification.respond_to?(:default_stubs)
def default_stubs def default_stubs
@ -871,47 +649,15 @@ module Bundler
def use_gemdeps(gemfile) def use_gemdeps(gemfile)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile) ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
require "bundler/gemdeps" require_relative "gemdeps"
runtime = Bundler.setup runtime = Bundler.setup
Bundler.ui = nil Bundler.ui = nil
activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name) activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
[Gemdeps.new(runtime), activated_spec_names] [Gemdeps.new(runtime), activated_spec_names]
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
end
end end
def self.rubygems def self.rubygems
@rubygems ||= if RubygemsIntegration.provides?(">= 2.1.0") @rubygems ||= RubygemsIntegration.new
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
end end
end end

View file

@ -34,14 +34,7 @@ module Bundler
spec.load_paths.reject {|path| $LOAD_PATH.include?(path) } spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
end.reverse.flatten end.reverse.flatten
# See Gem::Specification#add_self_to_load_path (since RubyGems 1.8) Bundler.rubygems.add_to_load_path(load_paths)
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
setup_manpath setup_manpath

View file

@ -4,9 +4,9 @@ require "uri"
module Bundler module Bundler
class Settings class Settings
autoload :Mirror, "bundler/mirror" autoload :Mirror, File.expand_path("mirror", __dir__)
autoload :Mirrors, "bundler/mirror" autoload :Mirrors, File.expand_path("mirror", __dir__)
autoload :Validator, "bundler/settings/validator" autoload :Validator, File.expand_path("settings/validator", __dir__)
BOOL_KEYS = %w[ BOOL_KEYS = %w[
allow_bundler_dependency_conflicts allow_bundler_dependency_conflicts
@ -28,14 +28,11 @@ module Bundler
disable_platform_warnings disable_platform_warnings
disable_shared_gems disable_shared_gems
disable_version_check disable_version_check
error_on_stderr
force_ruby_platform force_ruby_platform
forget_cli_options forget_cli_options
frozen frozen
gem.coc gem.coc
gem.mit gem.mit
github.https
global_path_appends_ruby_scope
global_gem_cache global_gem_cache
ignore_messages ignore_messages
init_gems_rb init_gems_rb
@ -207,23 +204,22 @@ module Bundler
locations locations
end end
# for legacy reasons, in Bundler 1, the ruby scope isnt appended when the setting comes from ENV or the global config, # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
# nor do we respect :disable_shared_gems
def path def path
key = key_for(:path) key = key_for(:path)
path = ENV[key] || @global_config[key] path = ENV[key] || @global_config[key]
if path && !@temporary.key?(key) && !@local_config.key?(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 end
system_path = self["path.system"] || (self[:disable_shared_gems] == false) 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 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 def path
path = base_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 path
end end
@ -358,7 +354,7 @@ module Bundler
return unless file return unless file
SharedHelpers.filesystem_access(file) do |p| SharedHelpers.filesystem_access(file) do |p|
FileUtils.mkdir_p(p.dirname) FileUtils.mkdir_p(p.dirname)
require "bundler/yaml_serializer" require_relative "yaml_serializer"
p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) } p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
end end
end end
@ -398,7 +394,7 @@ module Bundler
SharedHelpers.filesystem_access(config_file, :read) do |file| SharedHelpers.filesystem_access(config_file, :read) do |file|
valid_file = file.exist? && !file.size.zero? valid_file = file.exist? && !file.size.zero?
return {} unless valid_file return {} unless valid_file
require "bundler/yaml_serializer" require_relative "yaml_serializer"
YAMLSerializer.load file.read YAMLSerializer.load file.read
end end
end end

View file

@ -1,9 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/shared_helpers" require_relative "shared_helpers"
if Bundler::SharedHelpers.in_bundle? if Bundler::SharedHelpers.in_bundle?
require "bundler" require_relative "../bundler"
if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"] if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
Bundler.ui = Bundler::UI::Shell.new Bundler.ui = Bundler::UI::Shell.new

View file

@ -1,15 +1,15 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/compatibility_guard" require_relative "compatibility_guard"
require "pathname" require "pathname"
require "rbconfig" require "rbconfig"
require "rubygems" require "rubygems"
require "bundler/version" require_relative "version"
require "bundler/constants" require_relative "constants"
require "bundler/rubygems_integration" require_relative "rubygems_integration"
require "bundler/current_ruby" require_relative "current_ruby"
module Bundler module Bundler
module SharedHelpers module SharedHelpers
@ -103,9 +103,7 @@ module Bundler
# #
# @see {Bundler::PermissionError} # @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block) def filesystem_access(path, action = :write, &block)
# Use block.call instead of yield because of a bug in Ruby 2.2.2 yield(path.dup.untaint)
# See https://github.com/bundler/bundler/issues/5341 for details
block.call(path.dup.untaint)
rescue Errno::EACCES rescue Errno::EACCES
raise PermissionError.new(path, action) raise PermissionError.new(path, action)
rescue Errno::EAGAIN rescue Errno::EAGAIN
@ -132,7 +130,7 @@ module Bundler
def major_deprecation(major_version, message) def major_deprecation(major_version, message)
bundler_major_version = Bundler.bundler_major_version bundler_major_version = Bundler.bundler_major_version
if bundler_major_version > major_version if bundler_major_version > major_version
require "bundler/errors" require_relative "errors"
raise DeprecatedError, "[REMOVED] #{message}" raise DeprecatedError, "[REMOVED] #{message}"
end end
@ -289,20 +287,10 @@ module Bundler
public :set_env public :set_env
def set_bundle_variables 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__) exe_file = File.expand_path("../../../exe/bundle", __FILE__)
# for Ruby core repository # for Ruby core repository
exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file) 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_BIN_PATH", exe_file
end
# Set BUNDLE_GEMFILE
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s
Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
end end
@ -316,8 +304,9 @@ module Bundler
def set_rubyopt def set_rubyopt
rubyopt = [ENV["RUBYOPT"]].compact rubyopt = [ENV["RUBYOPT"]].compact
return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup} setup_require = "-r#{File.expand_path("setup", __dir__)}"
rubyopt.unshift %(-rbundler/setup) return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
rubyopt.unshift %(#{setup_require})
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ") Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
end end
@ -351,9 +340,9 @@ module Bundler
end end
def prints_major_deprecations? def prints_major_deprecations?
require "bundler" require_relative "../bundler"
return false if Bundler.settings[:silence_deprecations] return false if Bundler.settings[:silence_deprecations]
require "bundler/deprecate" require_relative "deprecate"
return false if Bundler::Deprecate.skip return false if Bundler::Deprecate.skip
true true
end end

View file

@ -2,11 +2,11 @@
module Bundler module Bundler
class Source class Source
autoload :Gemspec, "bundler/source/gemspec" autoload :Gemspec, File.expand_path("source/gemspec", __dir__)
autoload :Git, "bundler/source/git" autoload :Git, File.expand_path("source/git", __dir__)
autoload :Metadata, "bundler/source/metadata" autoload :Metadata, File.expand_path("source/metadata", __dir__)
autoload :Path, "bundler/source/path" autoload :Path, File.expand_path("source/path", __dir__)
autoload :Rubygems, "bundler/source/rubygems" autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
attr_accessor :dependency_names attr_accessor :dependency_names

View file

@ -1,12 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/vendored_fileutils" require_relative "../vendored_fileutils"
require "uri" require "uri"
module Bundler module Bundler
class Source class Source
class Git < Path 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 attr_reader :uri, :ref, :branch, :options, :submodules

View file

@ -13,10 +13,13 @@ module Bundler
idx << Gem::Specification.new do |s| idx << Gem::Specification.new do |s|
s.name = "bundler" s.name = "bundler"
s.version = VERSION s.version = VERSION
s.license = "MIT"
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.source = self s.source = self
s.authors = ["bundler team"] s.authors = ["bundler team"]
s.bindir = "exe" s.bindir = "exe"
s.homepage = "https://bundler.io"
s.summary = "The best way to manage your application's dependencies"
s.executables = %w[bundle] s.executables = %w[bundle]
# can't point to the actual gemspec or else the require paths will be wrong # can't point to the actual gemspec or else the require paths will be wrong
s.loaded_from = File.expand_path("..", __FILE__) s.loaded_from = File.expand_path("..", __FILE__)

View file

@ -3,7 +3,7 @@
module Bundler module Bundler
class Source class Source
class Path < 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_reader :path, :options, :root_path, :original_path
attr_writer :name attr_writer :name

View file

@ -6,7 +6,7 @@ require "rubygems/user_interaction"
module Bundler module Bundler
class Source class Source
class Rubygems < 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 # Use the API when installing less than X gems
API_REQUEST_LIMIT = 500 API_REQUEST_LIMIT = 500

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/remote_specification" require_relative "remote_specification"
module Bundler module Bundler
class StubSpecification < RemoteSpecification class StubSpecification < RemoteSpecification
@ -55,8 +55,6 @@ module Bundler
stub.full_require_paths stub.full_require_paths
end end
# This is what we do in bundler/rubygems_ext
# full_require_paths is always implemented
def load_paths def load_paths
full_require_paths full_require_paths
end end

View file

@ -1,6 +1,4 @@
lib = File.expand_path("lib", __dir__) require_relative 'lib/<%=config[:namespaced_path]%>/version'
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "<%= config[:namespaced_path] %>/version"
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = <%= config[:name].inspect %> spec.name = <%= config[:name].inspect %>

View file

@ -2,8 +2,8 @@
module Bundler module Bundler
module UI module UI
autoload :RGProxy, "bundler/ui/rg_proxy" autoload :RGProxy, File.expand_path("ui/rg_proxy", __dir__)
autoload :Shell, "bundler/ui/shell" autoload :Shell, File.expand_path("ui/shell", __dir__)
autoload :Silent, "bundler/ui/silent" autoload :Silent, File.expand_path("ui/silent", __dir__)
end end
end end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/ui" require_relative "../ui"
require "rubygems/user_interaction" require "rubygems/user_interaction"
module Bundler module Bundler

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/vendored_thor" require_relative "../vendored_thor"
module Bundler module Bundler
module UI module UI
@ -35,14 +35,12 @@ module Bundler
return if @warning_history.include? msg return if @warning_history.include? msg
@warning_history << msg @warning_history << msg
return tell_err(msg, :yellow, newline) if Bundler.feature_flag.error_on_stderr? tell_err(msg, :yellow, newline)
tell_me(msg, :yellow, newline)
end end
def error(msg, newline = nil) def error(msg, newline = nil)
return unless level("error") return unless level("error")
return tell_err(msg, :red, newline) if Bundler.feature_flag.error_on_stderr? tell_err(msg, :red, newline)
tell_me(msg, :red, newline)
end end
def debug(msg, newline = nil) def debug(msg, newline = nil)

View file

@ -2,7 +2,7 @@
module Bundler module Bundler
module URICredentialsFilter module URICredentialsFilter
module_function module_function # rubocop:disable Layout/AccessModifierIndentation
def credential_filtered_uri(uri_to_anonymize) def credential_filtered_uri(uri_to_anonymize)
return uri_to_anonymize if uri_to_anonymize.nil? return uri_to_anonymize if uri_to_anonymize.nil?

View file

@ -6,7 +6,7 @@ rescue LoadError
# for make mjit-headers # for make mjit-headers
end end
require "bundler/vendor/fileutils/lib/fileutils/version" require_relative "fileutils/version"
# #
# = fileutils.rb # = fileutils.rb

View file

@ -1,11 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/compatibility' require_relative 'molinillo/compatibility'
require 'bundler/vendor/molinillo/lib/molinillo/gem_metadata' require_relative 'molinillo/gem_metadata'
require 'bundler/vendor/molinillo/lib/molinillo/errors' require_relative 'molinillo/errors'
require 'bundler/vendor/molinillo/lib/molinillo/resolver' require_relative 'molinillo/resolver'
require 'bundler/vendor/molinillo/lib/molinillo/modules/ui' require_relative 'molinillo/modules/ui'
require 'bundler/vendor/molinillo/lib/molinillo/modules/specification_provider' require_relative 'molinillo/modules/specification_provider'
# Bundler::Molinillo is a generic dependency resolution algorithm. # Bundler::Molinillo is a generic dependency resolution algorithm.
module Bundler::Molinillo module Bundler::Molinillo

View file

@ -3,8 +3,8 @@
require 'set' require 'set'
require 'tsort' require 'tsort'
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/log' require_relative 'dependency_graph/log'
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex' require_relative 'dependency_graph/vertex'
module Bundler::Molinillo module Bundler::Molinillo
# A directed acyclic graph that is tuned to hold named dependencies # A directed acyclic graph that is tuned to hold named dependencies

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action' require_relative 'action'
module Bundler::Molinillo module Bundler::Molinillo
class DependencyGraph class DependencyGraph
# @!visibility private # @!visibility private

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action' require_relative 'action'
module Bundler::Molinillo module Bundler::Molinillo
class DependencyGraph class DependencyGraph
# @!visibility private # @!visibility private

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action' require_relative 'action'
module Bundler::Molinillo module Bundler::Molinillo
class DependencyGraph class DependencyGraph
# @!visibility private # @!visibility private

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action' require_relative 'action'
module Bundler::Molinillo module Bundler::Molinillo
class DependencyGraph class DependencyGraph
# @!visibility private # @!visibility private

View file

@ -1,11 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular' require_relative 'add_edge_no_circular'
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex' require_relative 'add_vertex'
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge' require_relative 'delete_edge'
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named' require_relative 'detach_vertex_named'
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload' require_relative 'set_payload'
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag' require_relative 'tag'
module Bundler::Molinillo module Bundler::Molinillo
class DependencyGraph class DependencyGraph

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action' require_relative 'action'
module Bundler::Molinillo module Bundler::Molinillo
class DependencyGraph class DependencyGraph
# @!visibility private # @!visibility private

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action' require_relative 'action'
module Bundler::Molinillo module Bundler::Molinillo
class DependencyGraph class DependencyGraph
# @!visibility private # @!visibility private

View file

@ -80,7 +80,7 @@ module Bundler::Molinillo
@specification_provider = specification_provider @specification_provider = specification_provider
end end
require 'bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider' require_relative 'delegates/specification_provider'
include Delegates::SpecificationProvider include Delegates::SpecificationProvider
# @return [String] An error message that includes requirement trees, # @return [String] An error message that includes requirement trees,

View file

@ -238,11 +238,11 @@ module Bundler::Molinillo
debug { 'Activated: ' + Hash[activated.vertices.select { |_n, v| v.payload }].keys.join(', ') } if state debug { 'Activated: ' + Hash[activated.vertices.select { |_n, v| v.payload }].keys.join(', ') } if state
end end
require 'bundler/vendor/molinillo/lib/molinillo/state' require_relative 'state'
require 'bundler/vendor/molinillo/lib/molinillo/modules/specification_provider' require_relative 'modules/specification_provider'
require 'bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state' require_relative 'delegates/resolution_state'
require 'bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider' require_relative 'delegates/specification_provider'
include Bundler::Molinillo::Delegates::ResolutionState include Bundler::Molinillo::Delegates::ResolutionState
include Bundler::Molinillo::Delegates::SpecificationProvider include Bundler::Molinillo::Delegates::SpecificationProvider

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph' require_relative 'dependency_graph'
module Bundler::Molinillo module Bundler::Molinillo
# This class encapsulates a dependency resolver. # This class encapsulates a dependency resolver.
@ -9,7 +9,7 @@ module Bundler::Molinillo
# #
# #
class Resolver class Resolver
require 'bundler/vendor/molinillo/lib/molinillo/resolution' require_relative 'resolution'
# @return [SpecificationProvider] the specification provider used # @return [SpecificationProvider] the specification provider used
# in the resolution process # in the resolution process

View file

@ -9,9 +9,9 @@ require "bundler/vendor/thor/lib/thor/line_editor"
require "bundler/vendor/thor/lib/thor/util" require "bundler/vendor/thor/lib/thor/util"
class Bundler::Thor class Bundler::Thor
autoload :Actions, "bundler/vendor/thor/lib/thor/actions" autoload :Actions, File.expand_path("actions", __dir__)
autoload :RakeCompat, "bundler/vendor/thor/lib/thor/rake_compat" autoload :RakeCompat, File.expand_path("rake_compat", __dir__)
autoload :Group, "bundler/vendor/thor/lib/thor/group" autoload :Group, File.expand_path("group", __dir__)
# Shortcuts for help. # Shortcuts for help.
HELP_MAPPINGS = %w(-h -? --help -D) HELP_MAPPINGS = %w(-h -? --help -D)

View file

@ -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] 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 attr_writer :shell
autoload :Basic, "bundler/vendor/thor/lib/thor/shell/basic" autoload :Basic, File.expand_path("shell/basic", __dir__)
autoload :Color, "bundler/vendor/thor/lib/thor/shell/color" autoload :Color, File.expand_path("shell/color", __dir__)
autoload :HTML, "bundler/vendor/thor/lib/thor/shell/html" autoload :HTML, File.expand_path("shell/html", __dir__)
# Add shell to initialize config values. # Add shell to initialize config values.
# #

View file

@ -2,7 +2,7 @@
module Bundler; end module Bundler; end
if RUBY_VERSION >= "2.4" if RUBY_VERSION >= "2.4"
require "bundler/vendor/fileutils/lib/fileutils" require_relative "vendor/fileutils/lib/fileutils"
else else
# the version we vendor is 2.4+ # the version we vendor is 2.4+
require "fileutils" require "fileutils"

View file

@ -1,4 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
module Bundler; end module Bundler; end
require "bundler/vendor/molinillo/lib/molinillo" require_relative "vendor/molinillo/lib/molinillo"

View file

@ -15,7 +15,7 @@ module Bundler
end end
end 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 module Bundler
class PersistentHTTP < Persistent::Net::HTTP::Persistent class PersistentHTTP < Persistent::Net::HTTP::Persistent

View file

@ -5,4 +5,4 @@ module Bundler
Kernel.send(:require, "bundler/vendor/thor/lib/thor/actions") Kernel.send(:require, "bundler/vendor/thor/lib/thor/actions")
end end
end end
require "bundler/vendor/thor/lib/thor" require_relative "vendor/thor/lib/thor"

View file

@ -1,23 +1,7 @@
# frozen_string_literal: false # frozen_string_literal: false
module Bundler module Bundler
# We're doing this because we might write tests that deal VERSION = "2.1.0.pre.1".freeze
# 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
def self.bundler_major_version def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i @bundler_major_version ||= VERSION.split(".").first.to_i

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/shared_helpers" require_relative "shared_helpers"
Bundler::SharedHelpers.major_deprecation 2, Bundler::SharedHelpers.major_deprecation 2,
"The Bundler task for Vlad" "The Bundler task for Vlad"
@ -8,7 +8,7 @@ Bundler::SharedHelpers.major_deprecation 2,
# #
# Add "require 'bundler/vlad'" in your Vlad deploy.rb, and # Add "require 'bundler/vlad'" in your Vlad deploy.rb, and
# include the vlad:bundle:install task in your vlad:deploy task. # include the vlad:bundle:install task in your vlad:deploy task.
require "bundler/deployment" require_relative "deployment"
include Rake::DSL if defined? Rake::DSL include Rake::DSL if defined? Rake::DSL

View file

@ -3,7 +3,7 @@
module Bundler module Bundler
# A stub yaml serializer that can handle only hashes and strings (as of now). # A stub yaml serializer that can handle only hashes and strings (as of now).
module YAMLSerializer module YAMLSerializer
module_function module_function # rubocop:disable Layout/AccessModifierIndentation
def dump(hash) def dump(hash)
yaml = String.new("---") yaml = String.new("---")

View file

@ -1,13 +1,13 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.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" .SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
. .
.SH "SYNOPSIS" .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" .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\. 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\. Specify the source for the added gem\.
. .
.TP .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 \fB\-\-skip\-install\fR
Adds the gem to the Gemfile but does not install it\. Adds the gem to the Gemfile but does not install it\.
. .

View file

@ -7,7 +7,8 @@ NAME
SYNOPSIS SYNOPSIS
bundle add GEM_NAME [--group=GROUP] [--version=VERSION] 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 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
@ -37,6 +38,11 @@ OPTIONS
--source, , -s --source, , -s
Specify the source for the added gem. 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 --skip-install
Adds the gem to the Gemfile but does not install it. 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)

View file

@ -3,7 +3,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install
## SYNOPSIS ## 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 ## DESCRIPTION
Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`. 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`: * `--source`, , `-s`:
Specify the source for the added gem. 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`: * `--skip-install`:
Adds the gem to the Gemfile but does not install it. Adds the gem to the Gemfile but does not install it.

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.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" .SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options \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\. \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 .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\. \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 .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\. \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 .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\. \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 .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\. \fBplugins\fR (\fBBUNDLE_PLUGINS\fR): Enable Bundler\'s experimental plugin system\.
. .
.IP "\(bu" 4 .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\. \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 .IP "\(bu" 4

View file

@ -221,9 +221,6 @@ LIST OF AVAILABLE KEYS
from checking if a newer Bundler version is available on from checking if a newer Bundler version is available on
rubygems.org. 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- o force_ruby_platform (BUNDLE_FORCE_RUBY_PLATFORM): Ignore the cur-
rent machine's platform and install only ruby platform gems. As a rent machine's platform and install only ruby platform gems. As a
result, gems with native extensions will be compiled from source. result, gems with native extensions will be compiled from source.
@ -247,11 +244,6 @@ LIST OF AVAILABLE KEYS
cache all gems globally, rather than locally to the installing Ruby cache all gems globally, rather than locally to the installing Ruby
installation. 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 o ignore_messages (BUNDLE_IGNORE_MESSAGES): When set, no post install
messages will be printed. To silence a single gem, use dot notation messages will be printed. To silence a single gem, use dot notation
like ignore_messages.httparty true. like ignore_messages.httparty true.
@ -287,9 +279,6 @@ LIST OF AVAILABLE KEYS
o plugins (BUNDLE_PLUGINS): Enable Bundler's experimental plugin sys- o plugins (BUNDLE_PLUGINS): Enable Bundler's experimental plugin sys-
tem. 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 o prefer_patch (BUNDLE_PREFER_PATCH): Prefer updating only to next
patch version during updates. Makes bundle update calls equivalent patch version during updates. Makes bundle update calls equivalent
to bundler update --patch. to bundler update --patch.
@ -533,4 +522,4 @@ CONFIGURE BUNDLER DIRECTORIES
April 2019 BUNDLE-CONFIG(1) May 2019 BUNDLE-CONFIG(1)

View file

@ -183,8 +183,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `disable_version_check` (`BUNDLE_DISABLE_VERSION_CHECK`): * `disable_version_check` (`BUNDLE_DISABLE_VERSION_CHECK`):
Stop Bundler from checking if a newer Bundler version is available on Stop Bundler from checking if a newer Bundler version is available on
rubygems.org. rubygems.org.
* `error_on_stderr` (`BUNDLE_ERROR_ON_STDERR`):
Print Bundler errors to stderr.
* `force_ruby_platform` (`BUNDLE_FORCE_RUBY_PLATFORM`): * `force_ruby_platform` (`BUNDLE_FORCE_RUBY_PLATFORM`):
Ignore the current machine's platform and install only `ruby` platform gems. Ignore the current machine's platform and install only `ruby` platform gems.
As a result, gems with native extensions will be compiled from source. 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`): * `global_gem_cache` (`BUNDLE_GLOBAL_GEM_CACHE`):
Whether Bundler should cache all gems globally, rather than locally to the Whether Bundler should cache all gems globally, rather than locally to the
installing Ruby installation. 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 * `ignore_messages` (`BUNDLE_IGNORE_MESSAGES`): When set, no post install
messages will be printed. To silence a single gem, use dot notation like messages will be printed. To silence a single gem, use dot notation like
`ignore_messages.httparty true`. `ignore_messages.httparty true`.

View file

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BUNDLE" "1" "April 2019" "" "" .TH "BUNDLE" "1" "May 2019" "" ""
. .
.SH "NAME" .SH "NAME"
\fBbundle\fR \- Ruby Dependency Management \fBbundle\fR \- Ruby Dependency Management
@ -89,7 +89,7 @@ Start an IRB session in the current bundle
Open an installed gem in the editor Open an installed gem in the editor
. .
.TP .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 Generate a lockfile for your dependencies
. .
.TP .TP

View file

@ -71,7 +71,7 @@ UTILITIES
bundle open(1) bundle-open.1.html bundle open(1) bundle-open.1.html
Open an installed gem in the editor 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 Generate a lockfile for your dependencies
bundle viz(1) bundle-viz.1.html bundle viz(1) bundle-viz.1.html
@ -113,4 +113,4 @@ OBSOLETE
April 2019 BUNDLE(1) May 2019 BUNDLE(1)

View file

@ -73,7 +73,7 @@ We divide `bundle` subcommands into primary commands and utilities:
* [`bundle open(1)`](bundle-open.1.html): * [`bundle open(1)`](bundle-open.1.html):
Open an installed gem in the editor 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 Generate a lockfile for your dependencies
* [`bundle viz(1)`](bundle-viz.1.html): * [`bundle viz(1)`](bundle-viz.1.html):

View file

@ -370,19 +370,15 @@ EOF
it { should be true } it { should be true }
end end
end end
end
describe "#requires_sudo?" do context "path writability" do
before 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/bundle")
FileUtils.mkdir_p("tmp/vendor/bin_dir") FileUtils.mkdir_p("tmp/vendor/bin_dir")
end end
after do after do
FileUtils.rm_rf("tmp/vendor/bundle") FileUtils.rm_rf("tmp/vendor/bundle")
FileUtils.rm_rf("tmp/vendor/bin_dir") FileUtils.rm_rf("tmp/vendor/bin_dir")
Bundler.remove_instance_variable(:@requires_sudo_ran)
Bundler.remove_instance_variable(:@requires_sudo)
end end
context "writable paths" do context "writable paths" do
it "should return false and display nothing" do it "should return false and display nothing" do
@ -421,6 +417,7 @@ MESSAGE
end end
end end
end end
end
context "user cache dir" do context "user cache dir" do
let(:home_path) { Pathname.new(ENV["HOME"]) } let(:home_path) { Pathname.new(ENV["HOME"]) }
@ -457,6 +454,7 @@ MESSAGE
it "should use custom home path as root for other paths" do it "should use custom home path as root for other paths" do
ENV["BUNDLE_USER_HOME"] = bundle_user_home_custom.to_s 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).to eq(bundle_user_home_custom)
expect(Bundler.user_bundle_path("home")).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")) expect(Bundler.user_bundle_path("cache")).to eq(bundle_user_home_custom.join("cache"))

View file

@ -30,8 +30,8 @@ RSpec.describe "bundle executable" do
context "with no arguments" do context "with no arguments" do
it "prints a concise help message", :bundler => "3" do it "prints a concise help message", :bundler => "3" do
bundle! "" bundle! ""
expect(last_command.stderr).to be_empty expect(err).to be_empty
expect(last_command.stdout).to include("Bundler version #{Bundler::VERSION}"). expect(out).to include("Bundler version #{Bundler::VERSION}").
and include("\n\nBundler commands:\n\n"). and include("\n\nBundler commands:\n\n").
and include("\n\n Primary commands:\n"). and include("\n\n Primary commands:\n").
and include("\n\n Utilities:\n"). and include("\n\n Utilities:\n").
@ -72,17 +72,17 @@ RSpec.describe "bundle executable" do
it "prints the running command" do it "prints the running command" do
gemfile "" gemfile ""
bundle! "info bundler", :verbose => true 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 end
it "doesn't print defaults" do it "doesn't print defaults" do
install_gemfile! "", :verbose => true 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
it "doesn't print defaults" do it "doesn't print defaults" do
install_gemfile! "", :verbose => true 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
end end
@ -125,7 +125,7 @@ RSpec.describe "bundle executable" do
let(:latest_version) { "222.0" } let(:latest_version) { "222.0" }
it "prints the version warning" do it "prints the version warning" do
bundle "fail" 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}. The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler` To install the latest version, run `gem install bundler`
EOS EOS
@ -150,7 +150,7 @@ To install the latest version, run `gem install bundler`
let(:latest_version) { "222.0.0.pre.4" } let(:latest_version) { "222.0.0.pre.4" }
it "prints the version warning" do it "prints the version warning" do
bundle "fail" 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}. The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler --pre` To install the latest version, run `gem install bundler --pre`
EOS EOS

View file

@ -25,61 +25,18 @@ RSpec.describe Bundler::Dsl do
expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption) expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption)
end end
context "github_https feature flag" do context "default hosts", :bundler => "2" do
it "is true when github.https is true" do it "converts :github to URI using https" do
bundle "config set github.https true" subject.gem("sparks", :github => "indirect/sparks")
expect(Bundler.feature_flag.github_https?).to eq true github_uri = "https://github.com/indirect/sparks.git"
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) expect(subject.dependencies.first.source.uri).to eq(github_uri)
end end
end
context "when shortcut repo is used" do it "converts :github shortcut to URI using https" do
let(:repo) { "rails" } subject.gem("sparks", :github => "rails")
github_uri = "https://github.com/rails/rails.git"
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) expect(subject.dependencies.first.source.uri).to eq(github_uri)
end 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"
end
context "by default", :bundler => "3" do
it_behaves_like "the github DSL", "https"
end
it "converts numeric :gist to :git" do it "converts numeric :gist to :git" do
subject.gem("not-really-a-gem", :gist => 2_859_988) subject.gem("not-really-a-gem", :gist => 2_859_988)
@ -106,7 +63,7 @@ RSpec.describe Bundler::Dsl do
end end
end end
context "default git sources", :bundler => "4" do context "default git sources", :bundler => "3" do
it "has none" do it "has none" do
expect(subject.instance_variable_get(:@git_sources)).to eq({}) expect(subject.instance_variable_get(:@git_sources)).to eq({})
end end
@ -285,7 +242,7 @@ RSpec.describe Bundler::Dsl do
end end
end end
describe "#github", :bundler => "3" do describe "#github", :bundler => "2" do
it "from github" do it "from github" do
spree_gems = %w[spree_core spree_api spree_backend] spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do subject.github "spree" do
@ -299,19 +256,6 @@ RSpec.describe Bundler::Dsl do
end end
describe "#github", :bundler => "3" 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 it "from github" do
expect do expect do
spree_gems = %w[spree_core spree_api spree_backend] spree_gems = %w[spree_core spree_api spree_backend]

View file

@ -1,5 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require "openssl"
require "bundler/settings" require "bundler/settings"
RSpec.describe Bundler::Env do RSpec.describe Bundler::Env do
@ -17,6 +18,54 @@ RSpec.describe Bundler::Env do
expect(out).to include(OpenSSL::OPENSSL_VERSION) expect(out).to include(OpenSSL::OPENSSL_VERSION)
end 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 context "when there is a Gemfile and a lockfile and print_gemfile is true" do
before do before do
gemfile "gem 'rack', '1.0.0'" gemfile "gem 'rack', '1.0.0'"

View file

@ -11,11 +11,14 @@ RSpec.describe Bundler::Fetcher::CompactIndex do
end end
describe "#specs_for_names" do 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 it "has only one thread open at the end of the run" do
compact_index.specs_for_names(["lskdjf"]) compact_index.specs_for_names(["lskdjf"])
thread_count = Thread.list.count {|thread| thread.status == "run" } thread_count = thread_list.count
expect(thread_count).to eq 1 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 end
it "calls worker#stop during the run" do it "calls worker#stop during the run" do

View file

@ -82,6 +82,15 @@ RSpec.describe Bundler::Fetcher::Downloader do
expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError, expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
/Authentication is required for www.uri-to-fetch.com/) /Authentication is required for www.uri-to-fetch.com/)
end 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 end
context "when the request response is a Net::HTTPNotFound" do context "when the request response is a Net::HTTPNotFound" do

View file

@ -35,11 +35,28 @@ RSpec.describe Bundler::Fetcher::Index do
context "when a 401 response occurs" do context "when a 401 response occurs" do
let(:error_message) { "401" } let(:error_message) { "401" }
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 it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do
expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError, expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
%r{Authentication is required for http://remote-uri.org}) %r{Authentication is required for http://remote-uri.org})
end end
end end
end
context "when a 403 response occurs" do context "when a 403 response occurs" do
let(:error_message) { "403" } let(:error_message) { "403" }

Some files were not shown because too many files have changed in this diff Show more