Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Commands::ExecCommand#load!
load!
lib/rubygems/commands/exec_command.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/commands/exec_command.rb, line 200
def load!
argv = ARGV.clone
ARGV.replace options[:args]
executable = options[:executable]
contains_executable = Gem.loaded_specs.values.select do |spec|
spec.executables.include?(executable)
end
if contains_executable.any? {|s| s.name == executable }
contains_executable.select! {|s| s.name == executable }
end
if contains_executable.empty?
spec = Gem.loaded_specs[executable]
if spec.nil? || spec.executables.empty?
alert_error "Failed to load executable `#{executable}`," \
" are you sure the gem `#{options[:gem_name]}` contains it?"
terminate_interaction 1
end
if spec.executables.size > 1
alert_error "Ambiguous which executable from gem `#{executable}` should be run: " \
"the options are #{spec.executables.sort}, specify one via COMMAND, and use `-g` and `-v` to specify gem and version"
terminate_interaction 1
end
contains_executable << spec
executable = spec.executable
end
if contains_executable.size > 1
alert_error "Ambiguous which gem `#{executable}` should come from: " \
"the options are #{contains_executable.map(&:name)}, " \
"specify one via `-g`"
terminate_interaction 1
end
old_exe = $0
$0 = executable
load Gem.activate_bin_path(contains_executable.first.name, executable, ">= 0.a")
ensure
$0 = old_exe if old_exe
ARGV.replace argv
end
No documentation available
See also
#install_if_needed
#print_command
#install
#set_gem_exec_install_paths
also in
4.0 · 3.4 · 3.3