diff options
author | Homu <homu@barosl.com> | 2016-07-18 23:54:08 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-07-18 23:54:08 +0900 |
commit | 5515464bfc38dda105496c4db3dc21cd223cc33e (patch) | |
tree | 8a881179f484ea4368a82286688ad42a4cccfd64 | |
parent | 0db993851608f961267bdbfcca37936a07df402f (diff) | |
parent | 550ba8a9de526bb56a853ddb3eef3bc003bd94a0 (diff) | |
download | bundler-5515464bfc38dda105496c4db3dc21cd223cc33e.tar.gz |
Auto merge of #4790 - ojab:master, r=segiddins
Improve exec on JRuby
Unfortunately I can't get testsuite running locally, hope that travis will tell that changes are OK.
Fixes https://github.com/bundler/bundler/issues/4586.
I don't really know if test should be added for the last commit, please advise.
-rw-r--r-- | lib/bundler/cli/exec.rb | 7 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 1 | ||||
-rw-r--r-- | spec/install/gemfile/path_spec.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 | ||||
-rw-r--r-- | spec/support/builders.rb | 7 |
5 files changed, 12 insertions, 9 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 4371887f2a..f0ce450959 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -25,7 +25,11 @@ module Bundler if bin_path = Bundler.which(cmd) return kernel_load(bin_path, *args) if ruby_shebang?(bin_path) # First, try to exec directly to something in PATH - kernel_exec([bin_path, cmd], *args) + if Bundler.current_ruby.jruby_18? + kernel_exec(bin_path, *args) + else + kernel_exec([bin_path, cmd], *args) + end else # exec using the given command kernel_exec(cmd, *args) @@ -77,6 +81,7 @@ module Bundler def ruby_shebang?(file) possibilities = [ "#!/usr/bin/env ruby\n", + "#!/usr/bin/env jruby\n", "#!#{Gem.ruby}\n", ] first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) } diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 4f24a0b162..577a13a1b5 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -70,7 +70,6 @@ describe "bundle install with git sources" do end it "sets up git gem executables on the path" do - pending_jruby_shebang_fix bundle "exec foobar" expect(out).to eq("1.0") end diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 50fc1abac5..9f2893a01c 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -265,8 +265,6 @@ describe "bundle install with explicit source paths" do end it "sets up executables" do - pending_jruby_shebang_fix - build_lib "foo" do |s| s.executables = "foobar" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d780a3f27b..a9266bf8cc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -85,10 +85,6 @@ RSpec.configure do |config| original_wd = Dir.pwd original_env = ENV.to_hash - def pending_jruby_shebang_fix - pending "JRuby executables do not have a proper shebang" if RUBY_PLATFORM == "java" - end - config.expect_with :rspec do |c| c.syntax = :expect end diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 00024db7cf..2491f87b77 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -534,8 +534,13 @@ module Spec @spec.executables = Array(val) @spec.executables.each do |file| executable = "#{@spec.bindir}/#{file}" + shebang = if Bundler.current_ruby.jruby? + "#!/usr/bin/env jruby\n" + else + "#!/usr/bin/env ruby\n" + end @spec.files << executable - write executable, "#!/usr/bin/env ruby\nrequire '#{@name}' ; puts #{Builders.constantize(@name)}" + write executable, "#{shebang}require '#{@name}' ; puts #{Builders.constantize(@name)}" end end |