ruby-changes:62221
From: MSP-Greg <ko1@a...>
Date: Wed, 15 Jul 2020 16:05:35 +0900 (JST)
Subject: [ruby-changes:62221] f3ad8a00e2 (master): [rubygems/rubygems] bundler/lib/bundler/installer.rb - fix Windows 'executable_stubs'
https://git.ruby-lang.org/ruby.git/commit/?id=f3ad8a00e2 From f3ad8a00e260184be1b63231e2f99a1ef73eba60 Mon Sep 17 00:00:00 2001 From: MSP-Greg <Greg.mpls@g...> Date: Tue, 16 Jun 2020 20:31:15 -0500 Subject: [rubygems/rubygems] bundler/lib/bundler/installer.rb - fix Windows 'executable_stubs' Windows normal shell requires binstubs with *.cmd extensions https://github.com/rubygems/rubygems/commit/b46326eb1f diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 44ef396..8be4bb1 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -135,12 +135,17 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/installer.rb#L135 next end - File.open(binstub_path, "w", 0o777 & ~File.umask) do |f| - if RUBY_VERSION >= "2.6" - f.puts ERB.new(template, :trim_mode => "-").result(binding) - else - f.puts ERB.new(template, nil, "-").result(binding) - end + mode = Bundler::WINDOWS ? "wb:UTF-8" : "w" + content = if RUBY_VERSION >= "2.6" + ERB.new(template, :trim_mode => "-").result(binding) + else + ERB.new(template, nil, "-").result(binding) + end + + File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask) + if Bundler::WINDOWS + prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n" + File.write("#{binstub_path}.cmd", prefix + content, :mode => mode) end end @@ -175,12 +180,18 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/installer.rb#L180 next if executable == "bundle" executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path) executable_path = executable_path - File.open "#{bin_path}/#{executable}", "w", 0o755 do |f| - if RUBY_VERSION >= "2.6" - f.puts ERB.new(template, :trim_mode => "-").result(binding) - else - f.puts ERB.new(template, nil, "-").result(binding) - end + + mode = Bundler::WINDOWS ? "wb:UTF-8" : "w" + content = if RUBY_VERSION >= "2.6" + ERB.new(template, :trim_mode => "-").result(binding) + else + ERB.new(template, nil, "-").result(binding) + end + + File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755) + if Bundler::WINDOWS + prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n" + File.write("#{bin_path}/#{executable}.cmd", prefix + content, :mode => mode) end end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/