Skip to content

Commit

Permalink
Make --standalone play nice with --local
Browse files Browse the repository at this point in the history
I'm not sure if using relative paths in the generated script is best for
this case, since it makes the script not movable, but that can be
improved later.
  • Loading branch information
deivid-rodriguez committed Jul 24, 2022
1 parent d695c8d commit 7f5bdbb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bundler/lib/bundler/cli/install.rb
Expand Up @@ -148,7 +148,7 @@ def normalize_settings
Bundler.settings.set_command_option :path, nil if options[:system]
Bundler.settings.set_command_option_if_given :path, options[:path]

if options["standalone"] && Bundler.settings[:path].nil?
if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
Bundler.settings.temporary(:path_relative_to_cwd => false) do
Bundler.settings.set_command_option :path, "bundle"
end
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/installer/standalone.rb
Expand Up @@ -47,7 +47,7 @@ def extensions_dir
end

def bundler_path
Bundler.root.join(Bundler.settings[:path], "bundler")
Bundler.root.join(Bundler.settings[:path].to_s, "bundler")
end

def gem_path(path, spec)
Expand Down
28 changes: 28 additions & 0 deletions bundler/spec/install/gems/standalone_spec.rb
Expand Up @@ -461,3 +461,31 @@

include_examples("bundle install --standalone")
end

RSpec.describe "bundle install --standalone --local" do
before do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G

system_gems "rack-1.0.0", :path => default_bundle_path
end

it "generates script pointing to system gems" do
bundle "install --standalone --local --verbose"

expect(out).to include("Using rack 1.0.0")

load_error_ruby <<-RUBY, "spec"
require "./bundler/setup"
require "rack"
puts RACK
require "spec"
RUBY

expect(out).to eq("1.0.0")
expect(err).to eq("ZOMG LOAD ERROR")
end
end

0 comments on commit 7f5bdbb

Please sign in to comment.