diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 0c89e416569..838dcb3e08f 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -262,6 +262,8 @@ def info(gem_name) "Overwrite existing binstubs if they exist" method_option "path", :type => :string, :lazy_default => "bin", :banner => "Binstub destination directory (default bin)" + method_option "shebang", :type => :string, :banner => + "Specify a different shebang executable name than the default (usually 'ruby')" method_option "standalone", :type => :boolean, :banner => "Make binstubs that can work without the Bundler runtime" def binstubs(*gems) diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb index 82815062d36..f872a2dcc78 100644 --- a/lib/bundler/cli/binstubs.rb +++ b/lib/bundler/cli/binstubs.rb @@ -13,6 +13,7 @@ def run Bundler.definition.validate_runtime! Bundler.settings[:bin] = options["path"] if options["path"] Bundler.settings[:bin] = nil if options["path"] && options["path"].empty? + Bundler.settings[:shebang] = options["shebang"] if options["shebang"] installer = Installer.new(Bundler.root, Bundler.definition) if gems.empty? diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index f3ca2301a76..430dbef314e 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -103,6 +103,19 @@ expect(File.stat(binary).mode.to_s(8)).to eq("100775") end end + + context "when using --shebang" do + it "sets the specified shebang for the the binstub" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle "binstubs rack --shebang jruby" + + expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env jruby\n") + end + end end context "when the gem doesn't exist" do