summaryrefslogtreecommitdiff
path: root/lib
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 /lib
parent93ebf9643dc0913693157e6b4bb391a549a9b8ae (diff)
Sync Bundler PR #3624 with HEAD commits
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3114
Diffstat (limited to 'lib')
-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
8 files changed, 37 insertions, 52 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