Skip to content

Commit efa41ba

Browse files
Fix generated standalone script for default gems
The installer is actually rewriting the spec's full gem path to be the one of the newly installed gem, however the accessor was not properly working for `StubSpecification` instances, and default gems are always of this type, because they are always present locally. Fix the accessor to properly update the underlying full specification.
1 parent 6e66ee4 commit efa41ba

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

bundler/lib/bundler/stub_specification.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def full_gem_path
6767
stub.full_gem_path
6868
end
6969

70+
def full_gem_path=(path)
71+
stub.full_gem_path = path
72+
end
73+
7074
def full_require_paths
7175
stub.full_require_paths
7276
end

bundler/spec/install/gems/standalone_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,16 @@
147147
bundle "lock", :dir => cwd, :artifice => "compact_index"
148148
end
149149

150-
it "works" do
150+
it "works and points to the vendored copies, not to the default copies" do
151151
bundle "config set --local path #{bundled_app("bundle")}"
152152
bundle :install, :standalone => true, :dir => cwd, :artifice => "compact_index", :env => { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }
153+
154+
load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") }
155+
156+
expect(load_path_lines).to eq [
157+
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/bar-1.0.0/lib")',
158+
'$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}/gems/foo-1.0.0/lib")',
159+
]
153160
end
154161
end
155162

0 commit comments

Comments
 (0)