зеркало из https://github.com/github/ruby.git
Sync Bundler PR #3624 with HEAD commits
This commit is contained in:
Родитель
93ebf9643d
Коммит
1d889c9656
|
@ -825,7 +825,7 @@ module Bundler
|
|||
Bundler::SharedHelpers.major_deprecation 2,\
|
||||
"The `#{flag_name}` flag is deprecated because it relies on being " \
|
||||
"remembered across bundler invocations, which bundler will no longer " \
|
||||
"do in future versions. Instead please use `bundle config set #{name} " \
|
||||
"do in future versions. Instead please use `bundle config set #{name.tr("-", "_")} " \
|
||||
"'#{value}'`, and stop using this flag"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -76,10 +76,10 @@ module Bundler
|
|||
end
|
||||
|
||||
def __materialize__
|
||||
search_object = Bundler.feature_flag.specific_platform? || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
|
||||
@specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
|
||||
source.gemspec.tap {|s| s.source = source }
|
||||
else
|
||||
search_object = Bundler.feature_flag.specific_platform? || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
|
||||
platform_object = Gem::Platform.new(platform)
|
||||
candidates = source.specs.search(search_object)
|
||||
same_platform_candidates = candidates.select do |spec|
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Psych could be a gem, so try to ask for it
|
||||
begin
|
||||
gem "psych"
|
||||
rescue LoadError
|
||||
end if defined?(gem)
|
||||
|
||||
# Psych could be in the stdlib
|
||||
# but it's too late if Syck is already loaded
|
||||
begin
|
||||
|
|
|
@ -47,15 +47,13 @@ module Gem
|
|||
full_require_paths
|
||||
end
|
||||
|
||||
if method_defined?(:extension_dir)
|
||||
alias_method :rg_extension_dir, :extension_dir
|
||||
def extension_dir
|
||||
@bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
|
||||
unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
|
||||
File.expand_path(File.join(extensions_dir, unique_extension_dir))
|
||||
else
|
||||
rg_extension_dir
|
||||
end
|
||||
alias_method :rg_extension_dir, :extension_dir
|
||||
def extension_dir
|
||||
@bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
|
||||
unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
|
||||
File.expand_path(File.join(extensions_dir, unique_extension_dir))
|
||||
else
|
||||
rg_extension_dir
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,12 +4,6 @@ require "rubygems/installer"
|
|||
|
||||
module Bundler
|
||||
class RubyGemsGemInstaller < Gem::Installer
|
||||
unless respond_to?(:at)
|
||||
def self.at(*args)
|
||||
new(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def check_executable_overwrite(filename)
|
||||
# Bundler needs to install gems regardless of binstub overwriting
|
||||
end
|
||||
|
@ -20,7 +14,7 @@ module Bundler
|
|||
|
||||
def build_extensions
|
||||
extension_cache_path = options[:bundler_extension_cache_path]
|
||||
return super unless extension_cache_path && extension_dir = Bundler.rubygems.spec_extension_dir(spec)
|
||||
return super unless extension_cache_path && extension_dir = spec.extension_dir
|
||||
|
||||
extension_dir = Pathname.new(extension_dir)
|
||||
build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
|
||||
|
|
|
@ -102,11 +102,6 @@ module Bundler
|
|||
end.flatten(1)
|
||||
end
|
||||
|
||||
def spec_extension_dir(spec)
|
||||
return unless spec.respond_to?(:extension_dir)
|
||||
spec.extension_dir
|
||||
end
|
||||
|
||||
def stub_set_spec(stub, spec)
|
||||
stub.instance_variable_set(:@spec, spec)
|
||||
end
|
||||
|
@ -223,11 +218,6 @@ module Bundler
|
|||
Gem.bin_path(gem, bin, ver)
|
||||
end
|
||||
|
||||
def preserve_paths
|
||||
# this is a no-op outside of RubyGems 1.8
|
||||
yield
|
||||
end
|
||||
|
||||
def loaded_gem_paths
|
||||
loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
|
||||
loaded_gem_paths.flatten
|
||||
|
|
|
@ -145,20 +145,17 @@ module Bundler
|
|||
|
||||
Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
|
||||
|
||||
installed_spec = nil
|
||||
Bundler.rubygems.preserve_paths do
|
||||
installed_spec = Bundler::RubyGemsGemInstaller.at(
|
||||
path,
|
||||
:install_dir => install_path.to_s,
|
||||
:bin_dir => bin_path.to_s,
|
||||
:ignore_dependencies => true,
|
||||
:wrappers => true,
|
||||
:env_shebang => true,
|
||||
:build_args => opts[:build_args],
|
||||
:bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
|
||||
:bundler_extension_cache_path => extension_cache_path(spec)
|
||||
).install
|
||||
end
|
||||
installed_spec = Bundler::RubyGemsGemInstaller.at(
|
||||
path,
|
||||
:install_dir => install_path.to_s,
|
||||
:bin_dir => bin_path.to_s,
|
||||
:ignore_dependencies => true,
|
||||
:wrappers => true,
|
||||
:env_shebang => true,
|
||||
:build_args => opts[:build_args],
|
||||
:bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
|
||||
:bundler_extension_cache_path => extension_cache_path(spec)
|
||||
).install
|
||||
spec.full_gem_path = installed_spec.full_gem_path
|
||||
|
||||
# SUDO HAX
|
||||
|
|
|
@ -28,9 +28,13 @@ module Bundler
|
|||
|
||||
# @!group Stub Delegates
|
||||
|
||||
# This is defined directly to avoid having to load every installed spec
|
||||
# This is defined directly to avoid having to loading the full spec
|
||||
def missing_extensions?
|
||||
stub.missing_extensions?
|
||||
return false if default_gem?
|
||||
return false if extensions.empty?
|
||||
return false if File.exist? gem_build_complete_path
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def activated
|
||||
|
@ -41,8 +45,16 @@ module Bundler
|
|||
stub.instance_variable_set(:@activated, activated)
|
||||
end
|
||||
|
||||
def default_gem
|
||||
stub.default_gem
|
||||
def extensions
|
||||
stub.extensions
|
||||
end
|
||||
|
||||
def gem_build_complete_path
|
||||
File.join(extension_dir, "gem.build_complete")
|
||||
end
|
||||
|
||||
def default_gem?
|
||||
stub.default_gem?
|
||||
end
|
||||
|
||||
def full_gem_path
|
||||
|
|
|
@ -15,6 +15,9 @@ else
|
|||
require "bundler"
|
||||
end
|
||||
|
||||
# Workaround for non-activated bundler spec due to missing https://github.com/rubygems/rubygems/commit/4e306d7bcdee924b8d80ca9db6125aa59ee4e5a3
|
||||
gem "bundler", Bundler::VERSION if Gem.rubygems_version < Gem::Version.new("2.6.2")
|
||||
|
||||
# Check if an older version of bundler is installed
|
||||
$LOAD_PATH.each do |path|
|
||||
next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
|
||||
|
|
|
@ -930,5 +930,24 @@ __FILE__: #{path.to_s.inspect}
|
|||
expect(err).to include("custom openssl should not be loaded")
|
||||
end
|
||||
end
|
||||
|
||||
context "with a git gem that includes extensions" do
|
||||
before do
|
||||
build_git "simple_git_binary", &:add_c_extension
|
||||
bundle! "config set --local path .bundle"
|
||||
install_gemfile! <<-G
|
||||
gem "simple_git_binary", :git => '#{lib_path("simple_git_binary-1.0")}'
|
||||
G
|
||||
end
|
||||
|
||||
it "allows calling bundle install" do
|
||||
bundle! "exec bundle install"
|
||||
end
|
||||
|
||||
it "allows calling bundle install after removing gem.build_complete" do
|
||||
FileUtils.rm_rf Dir[bundled_app(".bundle/**/gem.build_complete")]
|
||||
bundle! "exec #{Gem.ruby} -S bundle install"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -314,17 +314,18 @@ RSpec.describe "major deprecations" do
|
|||
end
|
||||
|
||||
{
|
||||
:clean => true,
|
||||
:deployment => true,
|
||||
:frozen => true,
|
||||
:"no-cache" => true,
|
||||
:"no-prune" => true,
|
||||
:path => "vendor/bundle",
|
||||
:shebang => "ruby27",
|
||||
:system => true,
|
||||
:without => "development",
|
||||
:with => "development",
|
||||
}.each do |name, value|
|
||||
"clean" => ["clean", true],
|
||||
"deployment" => ["deployment", true],
|
||||
"frozen" => ["frozen", true],
|
||||
"no-cache" => ["no_cache", true],
|
||||
"no-prune" => ["no_prune", true],
|
||||
"path" => ["path", "vendor/bundle"],
|
||||
"shebang" => ["shebang", "ruby27"],
|
||||
"system" => ["system", true],
|
||||
"without" => ["without", "development"],
|
||||
"with" => ["with", "development"],
|
||||
}.each do |name, expectations|
|
||||
option_name, value = *expectations
|
||||
flag_name = "--#{name}"
|
||||
|
||||
context "with the #{flag_name} flag" do
|
||||
|
@ -338,7 +339,7 @@ RSpec.describe "major deprecations" do
|
|||
"The `#{flag_name}` flag is deprecated because it relies on " \
|
||||
"being remembered across bundler invocations, which bundler " \
|
||||
"will no longer do in future versions. Instead please use " \
|
||||
"`bundle config set #{name} '#{value}'`, and stop using this flag"
|
||||
"`bundle config set #{option_name} '#{value}'`, and stop using this flag"
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ RSpec.describe "require 'bundler/gem_tasks'" do
|
|||
|
||||
bundled_app("Rakefile").open("w") do |f|
|
||||
f.write <<-RAKEFILE
|
||||
$:.unshift("#{lib_dir}")
|
||||
require "bundler/gem_tasks"
|
||||
RAKEFILE
|
||||
end
|
||||
|
@ -28,8 +27,8 @@ RSpec.describe "require 'bundler/gem_tasks'" do
|
|||
end
|
||||
|
||||
it "includes the relevant tasks" do
|
||||
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
|
||||
sys_exec "#{rake} -T", :env => { "RUBYOPT" => opt_add("-I#{lib_dir}", ENV["RUBYOPT"]) }
|
||||
with_gem_path_as(base_system_gems.to_s) do
|
||||
sys_exec "#{rake} -T", :env => { "GEM_HOME" => system_gem_path.to_s }
|
||||
end
|
||||
|
||||
expect(err).to be_empty
|
||||
|
@ -46,8 +45,8 @@ RSpec.describe "require 'bundler/gem_tasks'" do
|
|||
end
|
||||
|
||||
it "defines a working `rake install` task" do
|
||||
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
|
||||
sys_exec "#{rake} install", :env => { "RUBYOPT" => opt_add("-I#{lib_dir}", ENV["RUBYOPT"]) }
|
||||
with_gem_path_as(base_system_gems.to_s) do
|
||||
sys_exec "#{rake} install", :env => { "GEM_HOME" => system_gem_path.to_s }
|
||||
end
|
||||
|
||||
expect(err).to be_empty
|
||||
|
@ -69,9 +68,27 @@ RSpec.describe "require 'bundler/gem_tasks'" do
|
|||
end
|
||||
end
|
||||
|
||||
context "bundle path configured locally" do
|
||||
before do
|
||||
bundle "config set path vendor/bundle"
|
||||
end
|
||||
|
||||
it "works" do
|
||||
install_gemfile! <<-G
|
||||
source "#{file_uri_for(gem_repo1)}"
|
||||
|
||||
gem "rake"
|
||||
G
|
||||
|
||||
bundle! "exec rake -T"
|
||||
|
||||
expect(err).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
it "adds 'pkg' to rake/clean's CLOBBER" do
|
||||
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
|
||||
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
|
||||
with_gem_path_as(base_system_gems.to_s) do
|
||||
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect'), :env => { "GEM_HOME" => system_gem_path.to_s }
|
||||
end
|
||||
expect(out).to eq '["pkg"]'
|
||||
end
|
||||
|
|
|
@ -767,13 +767,11 @@ end
|
|||
G
|
||||
|
||||
ruby <<-R
|
||||
if Gem::Specification.method_defined? :extension_dir
|
||||
s = Gem::Specification.find_by_name '#{gem_name}'
|
||||
s.extension_dir = '#{ext_dir}'
|
||||
s = Gem::Specification.find_by_name '#{gem_name}'
|
||||
s.extension_dir = '#{ext_dir}'
|
||||
|
||||
# Don't build extensions.
|
||||
s.class.send(:define_method, :build_extensions) { nil }
|
||||
end
|
||||
# Don't build extensions.
|
||||
s.class.send(:define_method, :build_extensions) { nil }
|
||||
|
||||
require '#{lib_dir}/bundler'
|
||||
gem '#{gem_name}'
|
||||
|
|
Загрузка…
Ссылка в новой задаче