Skip to content

Commit

Permalink
Merge pull request #5586 from rubygems/standalone-default-gems
Browse files Browse the repository at this point in the history
Fix generated standalone script when it includes default gems
  • Loading branch information
deivid-rodriguez committed Jun 1, 2022
2 parents 5d6b328 + efa41ba commit 7f464c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions bundler/lib/bundler/stub_specification.rb
Expand Up @@ -64,9 +64,11 @@ def default_gem?
end

def full_gem_path
# deleted gems can have their stubs return nil, so in that case grab the
# expired path from the full spec
stub.full_gem_path || method_missing(:full_gem_path)
stub.full_gem_path
end

def full_gem_path=(path)
stub.full_gem_path = path
end

def full_require_paths
Expand Down
9 changes: 8 additions & 1 deletion bundler/spec/install/gems/standalone_spec.rb
Expand Up @@ -147,9 +147,16 @@
bundle "lock", :dir => cwd, :artifice => "compact_index"
end

it "works" do
it "works and points to the vendored copies, not to the default copies" do
bundle "config set --local path #{bundled_app("bundle")}"
bundle :install, :standalone => true, :dir => cwd, :artifice => "compact_index", :env => { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }

load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") }

expect(load_path_lines).to eq [
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/bar-1.0.0/lib")',
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/foo-1.0.0/lib")',
]
end
end

Expand Down

0 comments on commit 7f464c0

Please sign in to comment.