Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Gem::Commands::SetupCommand#install_executables
install_executables(bin_dir)
lib/rubygems/commands/setup_command.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/rubygems/commands/setup_command.rb, line 245
def install_executables(bin_dir)
prog_mode = options[:prog_mode] || 0o755
executables = { "gem" => "exe" }
executables.each do |tool, path|
say "Installing #{tool} executable" if @verbose
Dir.chdir path do
bin_file = "gem"
require "tmpdir"
dest_file = target_bin_path(bin_dir, bin_file)
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
begin
bin = File.readlines bin_file
bin[0] = shebang
File.open bin_tmp_file, "w" do |fp|
fp.puts bin.join
end
install bin_tmp_file, dest_file, mode: prog_mode
bin_file_names << dest_file
ensure
rm bin_tmp_file
end
next unless Gem.win_platform?
begin
bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat"
File.open bin_cmd_file, "w" do |file|
file.puts <<-TEXT
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
TEXT
end
install bin_cmd_file, "#{dest_file}.bat", mode: prog_mode
ensure
rm bin_cmd_file
end
end
end
end
No documentation available
See also
#install_default_bundler_gem
#install_file
#generate_default_man_dir
#install_file_list
also in
4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0