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

Commit

Permalink
Add --shebang option to bundle install to use a different executable …
Browse files Browse the repository at this point in the history
…than the default ruby install name
  • Loading branch information
bensie committed Oct 2, 2011
1 parent 95bb144 commit 3ade143
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def check
"Do not attempt to fetch gems remotely and use the gem cache instead"
method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
"Generate bin stubs for bundled gems to ./bin"
method_option "shebang", :type => :string, :banner =>
"Specify a different shebang executable name than the default (usually 'ruby')"
method_option "path", :type => :string, :banner =>
"Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
method_option "system", :type => :boolean, :banner =>
Expand Down Expand Up @@ -204,6 +206,7 @@ def install
Bundler.settings[:path] = opts[:path] if opts[:path]
Bundler.settings[:path] ||= "bundle" if opts[:standalone]
Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs]
Bundler.settings[:shebang] = opts["shebang"] if opts[:shebang]
Bundler.settings[:no_prune] = true if opts["no-prune"]
Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil
Bundler.settings.without = opts[:without]
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/templates/Executable
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env <%= RbConfig::CONFIG['ruby_install_name'] %>
#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG['ruby_install_name'] %>
#
# This file was generated by Bundler.
#
Expand Down
10 changes: 10 additions & 0 deletions spec/runtime/executable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
out.should == "1.0.0"
end

it "uses the default ruby install name when shebang is not specified" do
bundle "install --binstubs"
File.open("bin/rackup").gets.should == "#!/usr/bin/env #{RbConfig::CONFIG['ruby_install_name']}\n"
end

it "allows the name of the shebang executable to be specified" do
bundle "install --binstubs --shebang ruby-foo"
File.open("bin/rackup").gets.should == "#!/usr/bin/env ruby-foo\n"
end

it "runs the bundled command when out of the bundle" do
bundle "install --binstubs"

Expand Down

0 comments on commit 3ade143

Please sign in to comment.