summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/cli/exec.rb2
-rw-r--r--spec/commands/exec_spec.rb7
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb
index 4f304975ce..865ac20248 100644
--- a/lib/bundler/cli/exec.rb
+++ b/lib/bundler/cli/exec.rb
@@ -75,7 +75,7 @@ module Bundler
"#!/usr/bin/env ruby\n",
"#!#{Gem.ruby}\n",
]
- first_line = File.read(file, possibilities.map(&:size).max, :mode => "rb")
+ first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) }
possibilities.any? {|shebang| first_line.start_with?(shebang) }
end
end
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index e6c22ead43..be2f8aa2a5 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -378,7 +378,7 @@ describe "bundle exec" do
before do
path.open("w") {|f| f << executable }
- FileUtils.chmod("+x", path)
+ path.chmod(0755)
install_gemfile <<-G
gem "rack"
@@ -422,7 +422,10 @@ describe "bundle exec" do
let(:executable) { super() << "\nraise 'ERROR'" }
let(:exit_code) { 1 }
let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" }
- let(:expected_err) { "RuntimeError: ERROR\n #{path}:7:in `<top (required)>'" }
+ let(:expected_err) do
+ "RuntimeError: ERROR\n #{path}:7" +
+ (Bundler.current_ruby.ruby_18? ? "" : ":in `<top (required)>'")
+ end
it_behaves_like "it runs"
end