Class: Kompo::CargoPath::Installed

Inherits:
Taski::Task
  • Object
show all
Defined in:
lib/kompo/tasks/cargo_path.rb

Overview

Use existing Cargo installation

Instance Method Summary collapse

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kompo/tasks/cargo_path.rb', line 17

def run
  # First check PATH, then fallback to default rustup location
  cargo_in_path, = Open3.capture2("which", "cargo", err: File::NULL)
  cargo_in_path = cargo_in_path.chomp
  @path = if cargo_in_path.empty?
    File.expand_path("~/.cargo/bin/cargo")
  else
    cargo_in_path
  end
  puts "Cargo path: #{@path}"
  version_output, = Open3.capture2e(@path, "--version")
  puts "Cargo version: #{version_output.chomp}"
end