[前][次][番号順一覧][スレッド一覧]

ruby-changes:61322

From: Hiroshi <ko1@a...>
Date: Fri, 22 May 2020 20:32:56 +0900 (JST)
Subject: [ruby-changes:61322] 1d889c9656 (master): Sync Bundler PR #3624 with HEAD commits

https://git.ruby-lang.org/ruby.git/commit/?id=1d889c9656

From 1d889c96562e9619d2cab443da711e82daeb983c Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Thu, 21 May 2020 21:05:07 +0900
Subject: Sync Bundler PR #3624 with HEAD commits


diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index d679482..f761328 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -825,7 +825,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L825
       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 a6aeb16..ad8488d 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -76,10 +76,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lazy_specification.rb#L76
     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 aeb2b30..463d52d 100644
--- a/lib/bundler/psyched_yaml.rb
+++ b/lib/bundler/psyched_yaml.rb
@@ -1,11 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/psyched_yaml.rb#L1
 # 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 8aa87d8..66f9a45 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -47,15 +47,13 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_ext.rb#L47
       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 b1076b4..8ce33c3 100644
--- a/lib/bundler/rubygems_gem_installer.rb
+++ b/lib/bundler/rubygems_gem_installer.rb
@@ -4,12 +4,6 @@ require "rubygems/installer" https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_gem_installer.rb#L4
 
 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 https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_gem_installer.rb#L14
 
     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 0ff3df9..b6f9384 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -102,11 +102,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_integration.rb#L102
       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 https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_integration.rb#L218
       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 6c0de20..ee11fed 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -145,20 +145,17 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L145
 
           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 d45f80a..c87b66e 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -28,9 +28,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/stub_specification.rb#L28
 
     # @!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 https://github.com/ruby/ruby/blob/trunk/lib/bundler/stub_specification.rb#L45
       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 b3b1b69..1168e5a 100755
--- a/libexec/bundle
+++ b/libexec/bundle
@@ -15,6 +15,9 @@ else https://github.com/ruby/ruby/blob/trunk/libexec/bundle#L15
   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 773ee5f..b387419 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -930,5 +930,24 @@ __FILE__: #{path.to_s.inspect} https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L930
         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 instal (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]