From aba5e40d174bd8127377718013b0f2fb78939d40 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Thu, 6 Apr 2017 20:53:57 -0500 Subject: [StubSpecification] Properly handle full_gem_path for git gems --- lib/bundler/remote_specification.rb | 5 +++++ lib/bundler/rubygems_integration.rb | 6 ++++-- lib/bundler/source/git.rb | 1 + lib/bundler/stub_specification.rb | 11 +---------- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index c689af46c5..82b5cb8c6f 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -82,6 +82,11 @@ module Bundler @dependencies || method_missing(:dependencies) end + def git_version + return unless loaded_from && source.is_a?(Bundler::Source::Git) + " #{source.revision[0..6]}" + end + private def to_ary diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 51655dbeea..5b753618cb 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -437,8 +437,10 @@ module Bundler # Copy of Rubygems activate_bin_path impl requirement = args.last spec = find_spec_for_exe name, exec_name, [requirement] - Gem::LOADED_SPECS_MUTEX.synchronize { spec.activate } - spec.bin_file exec_name + + gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name) + gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name) + File.exist?(gem_bin) ? gem_bin : gem_from_path_bin end redefine_method(gem_class, :bin_path) do |name, *args| diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index d92b741202..dd515166c2 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -307,6 +307,7 @@ module Bundler if defined?(::Gem::StubSpecification) def load_gemspec(file) stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent) + stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.untaint StubSpecification.from_stub(stub) end end diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index 2e8938e12d..9e43f06364 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -36,17 +36,8 @@ module Bundler stub.default_gem end - # This is what we do in bundler/rubygems_ext def full_gem_path - # this cannot check source.is_a?(Bundler::Plugin::API::Source) - # because that _could_ trip the autoload, and if there are unresolved - # gems at that time, this method could be called inside another require, - # thus raising with that constant being undefined. Better to check a method - if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?) - Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.untaint - else - rg_full_gem_path - end + stub.full_gem_path end def full_require_paths -- cgit v1.2.1