Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Setup custom Gemfile path before loading bundler for binstubs #6201

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/bundler/templates/Executable
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
# this file is here to facilitate running it.
#

bundle_binstub = File.expand_path("../bundle", __FILE__)
load(bundle_binstub) if File.file?(bundle_binstub)

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
load(bundle_binstub) if File.file?(bundle_binstub)

require "rubygems"
require "bundler/setup"

Expand Down
29 changes: 29 additions & 0 deletions spec/runtime/executable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,33 @@

expect(bundled_app("bin/rackup").read).to_not eq("OMG")
end

it "use BUNDLE_GEMFILE gemfile for binstub" do
# context with bin/bunlder w/ default Gemfile
bundle! "binstubs bundler"

# generate other Gemfile with executable gem
build_repo2 do
build_gem("bindir") {|s| s.executables = "foo" }
end

create_file("OtherGemfile", <<-G)
source "file://#{gem_repo2}"
gem 'bindir'
G

# generate binstub for executable from non default Gemfile (other then bin/bundler version)
ENV["BUNDLE_GEMFILE"] = "OtherGemfile"
bundle "install"
bundle! "binstubs bindir"

# remove user settings
ENV["BUNDLE_GEMFILE"] = nil

# run binstub for non default Gemfile
gembin "foo"

expect(exitstatus).to eq(0) if exitstatus
expect(out).to eq("1.0")
end
end