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

Commit

Permalink
Setup Gemfile path before loading bundler in order to use original Ge…
Browse files Browse the repository at this point in the history
…mfile
  • Loading branch information
pftg committed Dec 2, 2017
1 parent 778dcf5 commit 0f62f28
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
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

0 comments on commit 0f62f28

Please sign in to comment.