summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-21 21:05:07 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-22 20:32:30 +0900
commit1d889c96562e9619d2cab443da711e82daeb983c (patch)
tree0a6a142360be987ceaff6cbf24a03fd5797ecb66
parent93ebf9643dc0913693157e6b4bb391a549a9b8ae (diff)
Sync Bundler PR #3624 with HEAD commits
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3114
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/lazy_specification.rb2
-rw-r--r--lib/bundler/psyched_yaml.rb6
-rw-r--r--lib/bundler/rubygems_ext.rb16
-rw-r--r--lib/bundler/rubygems_gem_installer.rb8
-rw-r--r--lib/bundler/rubygems_integration.rb10
-rw-r--r--lib/bundler/source/rubygems.rb25
-rw-r--r--lib/bundler/stub_specification.rb20
-rwxr-xr-xlibexec/bundle3
-rw-r--r--spec/bundler/commands/exec_spec.rb19
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb25
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb31
-rw-r--r--spec/bundler/runtime/setup_spec.rb10
13 files changed, 100 insertions, 77 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index d679482a3a..f7613287d0 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -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
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index a6aeb16648..ad8488d089 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -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|
diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb
index aeb2b30310..463d52dc4a 100644
--- a/lib/bundler/psyched_yaml.rb
+++ b/lib/bundler/psyched_yaml.rb
@@ -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
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 8aa87d8f7d..66f9a45cbd 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -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
diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb
index b1076b4554..8ce33c3953 100644
--- a/lib/bundler/rubygems_gem_installer.rb
+++ b/lib/bundler/rubygems_gem_installer.rb
@@ -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?)
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 0ff3df9a08..b6f9384657 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -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
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 6c0de204e7..ee11feda5c 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -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
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
index d45f80a80a..c87b66ee19 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -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
diff --git a/libexec/bundle b/libexec/bundle
index b3b1b691d8..1168e5a361 100755
--- a/libexec/bundle
+++ b/libexec/bundle
@@ -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
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index 773ee5fab5..b387419726 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -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
diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb
index e9398e3b24..102588e97a 100644
--- a/spec/bundler/other/major_deprecation_spec.rb
+++ b/spec/bundler/other/major_deprecation_spec.rb
@@ -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
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
index 9d673bb9cc..a81eaf5468 100644
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ b/spec/bundler/runtime/gem_tasks_spec.rb
@@ -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
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index 5975218c48..c16515147e 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -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}'