Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::DependencyInstaller#install
install(dep_or_name, version = Gem::Requirement.default)
lib/rubygems/dependency_installer.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/dependency_installer.rb, line 161
def install(dep_or_name, version = Gem::Requirement.default)
request_set = resolve_dependencies dep_or_name, version
@installed_gems = []
options = {
bin_dir: @bin_dir,
build_args: @build_args,
build_jobs: @build_jobs,
document: @document,
env_shebang: @env_shebang,
force: @force,
format_executable: @format_executable,
ignore_dependencies: @ignore_dependencies,
prerelease: @prerelease,
security_policy: @security_policy,
user_install: @user_install,
wrappers: @wrappers,
build_root: @build_root,
dir_mode: @dir_mode,
data_mode: @data_mode,
prog_mode: @prog_mode,
build_extension: @build_extension,
install_plugin: @install_plugin,
}
options[:install_dir] = @install_dir if @only_install_dir
request_set.install options do |_, installer|
@installed_gems << installer.spec if installer
end
@installed_gems.sort!
# Since this is currently only called for docs, we can be lazy and just say
# it's documentation. Ideally the hook adder could decide whether to be in
# the background or not, and what to call it.
in_background "Installing documentation" do
Gem.done_installing_hooks.each do |hook|
hook.call self, @installed_gems
end
end unless Gem.done_installing_hooks.empty?
@installed_gems
end
Installs the gem dep_or_name and all its dependencies. Returns an Array of installed gem specifications.
If the :prerelease option is set and there is a prerelease for dep_or_name the prerelease version will be installed.
Unless explicitly specified as a prerelease dependency, prerelease gems that dep_or_name depend on will not be installed.
If c-1.a depends on b-1 and a-1.a and there is a gem b-1.a available then c-1.a, b-1 and a-1.a will be installed. b-1.a will need to be installed separately.