Exception: RbSys::CargoMetadataError

Inherits:
Error
  • Object
show all
Defined in:
lib/rb_sys/error.rb

Overview

Raised when Cargo metadata cannot be parsed.

Instance Method Summary collapse

Constructor Details

#initialize(err, stderr) ⇒ CargoMetadataError

Returns a new instance of CargoMetadataError.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rb_sys/error.rb', line 22

def initialize(err, stderr)
  msg = <<~MSG.chomp.tr("\n", " ")
    Could not infer Rust crate information using `cargo metadata`.

    Original error was:
      #{err.class}: #{err.message}

    Things to check:
      - Check that your ext/*/Cargo.toml at is valid
      - If you are using a workspace, make sure you are the root Cargo.toml exists
      - Make sure `cargo` is installed and in your PATH
  MSG

  if !stderr.empty?
    indented_stderr = stderr.lines.map { |line| "  #{line}" }.join
    msg << "Stderr from `cargo metadata` was:\n#{indented_stderr}"
  end

  super(msg)
end