Module: Homebrew::Bundle::CargoInstaller Private

Defined in:
bundle/cargo_installer.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Class Method Summary collapse

Class Method Details

.install!(name, preinstall: true, verbose: false, force: false, **_options) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • name (String)
  • preinstall (Boolean) (defaults to: true)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)
  • _options (T.anything)

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'bundle/cargo_installer.rb', line 38

def self.install!(name, preinstall: true, verbose: false, force: false, **_options)
  return true unless preinstall

  puts "Installing #{name} Cargo package. It is not currently installed." if verbose

  cargo = T.must(Bundle.which_cargo)
  env = { "PATH" => "#{cargo.dirname}:#{ENV.fetch("PATH")}" }
  success = with_env(env) do
    Bundle.system cargo.to_s, "install", "--locked", name, verbose:
  end
  return false unless success

  installed_packages << name
  true
end

.installed_packagesArray<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



60
61
62
63
# File 'bundle/cargo_installer.rb', line 60

def self.installed_packages
  require "bundle/cargo_dumper"
  @installed_packages ||= T.let(Homebrew::Bundle::CargoDumper.packages, T.nilable(T::Array[String]))
end

.package_installed?(package) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (Boolean)


55
56
57
# File 'bundle/cargo_installer.rb', line 55

def self.package_installed?(package)
  installed_packages.include? package
end

.preinstall!(name, verbose: false, **_options) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • name (String)
  • verbose (Boolean) (defaults to: false)
  • _options (T.anything)

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'bundle/cargo_installer.rb', line 13

def self.preinstall!(name, verbose: false, **_options)
  unless Bundle.cargo_installed?
    puts "Installing rust for cargo. It is not currently installed." if verbose
    Bundle.brew("install", "--formula", "rust", verbose:)
    Bundle.reset!
    raise "Unable to install #{name} package. Rust installation failed." unless Bundle.cargo_installed?
  end

  if package_installed?(name)
    puts "Skipping install of #{name} Cargo package. It is already installed." if verbose
    return false
  end

  true
end

.reset!void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



8
9
10
# File 'bundle/cargo_installer.rb', line 8

def self.reset!
  @installed_packages = nil
end