summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Nikitochkin <pftg@users.noreply.github.com>2017-12-02 18:04:41 +0200
committerPaul Nikitochkin <pftg@users.noreply.github.com>2017-12-02 23:26:20 +0200
commit0f62f28b21c5ece35d26aaf6d822976ad8af1ee1 (patch)
treeaef56cef67fc43d7ee99a42392672ea80fa0c0e6
parent778dcf58506b99fc7923a1ae530f1353dee9a4d4 (diff)
downloadbundler-0f62f28b21c5ece35d26aaf6d822976ad8af1ee1.tar.gz
Setup Gemfile path before loading bundler in order to use original Gemfile
-rwxr-xr-xlib/bundler/templates/Executable6
-rw-r--r--spec/runtime/executable_spec.rb29
2 files changed, 32 insertions, 3 deletions
diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable
index 9289debc26..4e35e586db 100755
--- a/lib/bundler/templates/Executable
+++ b/lib/bundler/templates/Executable
@@ -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"
diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb
index 388ee049d0..dcee234e15 100644
--- a/spec/runtime/executable_spec.rb
+++ b/spec/runtime/executable_spec.rb
@@ -158,4 +158,33 @@ RSpec.describe "Running bin/* commands" do
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