instance method
Gem::Installer#windows_stub_script
windows_stub_script(bindir, bin_file_name)
lib/rubygems/installer.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/installer.rb, line 770
def windows_stub_script(bindir, bin_file_name)
rb_topdir = RbConfig::TOPDIR || File.dirname(rb_config["bindir"])
# get ruby executable file name from RbConfig
ruby_exe = "#{rb_config["RUBY_INSTALL_NAME"]}#{rb_config["EXEEXT"]}"
ruby_exe = "ruby.exe" if ruby_exe.empty?
if File.exist?(File.join(bindir, ruby_exe))
# stub & ruby.exe within same folder. Portable
<<~TEXT
@ECHO OFF
@"%~dp0#{ruby_exe}" "%~dpn0" %*
TEXT
elsif bindir.downcase.start_with? rb_topdir.downcase
# stub within ruby folder, but not standard bin. Portable
require "pathname"
from = Pathname.new bindir
to = Pathname.new "#{rb_topdir}/bin"
rel = to.relative_path_from from
<<~TEXT
@ECHO OFF
@"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %*
TEXT
else
# outside ruby folder, maybe -user-install or bundler. Portable, but ruby
# is dependent on PATH
<<~TEXT
@ECHO OFF
@#{ruby_exe} "%~dpn0" %*
TEXT
end
end
return the stub script text used to launch the true Ruby script
See also
#verify_spec
#write_build_info_file
#user_install_dir
#write_cache_file
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0