Skip to content

Commit

Permalink
Always avoid loading the full spec when checking extensions
Browse files Browse the repository at this point in the history
By explicitly defining a couple more methods, we can avoid loading the
full specification in all cases, including pathological ones that
currently lead to stackoverflow errors.
  • Loading branch information
segiddins authored and deivid-rodriguez committed May 19, 2020
1 parent c03df5a commit 226ec11
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bundler/lib/bundler/stub_specification.rb
Expand Up @@ -30,7 +30,11 @@ def to_yaml

# 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
Expand All @@ -41,6 +45,14 @@ def activated=(activated)
stub.instance_variable_set(:@activated, activated)
end

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
Expand Down
19 changes: 19 additions & 0 deletions bundler/spec/commands/exec_spec.rb
Expand Up @@ -928,5 +928,24 @@ def bin_path(a,b,c)
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

0 comments on commit 226ec11

Please sign in to comment.