Cargo ignoring all dependencies

I have recently installed rust and was just setting up my vscode environment when I came across a problem that I can't seem to figure out, as well as a lot of google searches it seems nobody else has this problem. No dependencies will compile as they are all ignored. I have tried running the update and clean command. The only extensions I have on vscode are "crates" and "rust-analyzer".

Here's my files

main.rs:

fn main() {
    println!("Hello, world!");
}

Cargo.toml

[package]
name = "guessing_gamer"
version = "0.1.0"
edition = "2021"

[dependencies]
irust = "1.71.4"

Console commands:

PS C:\Users\xxsha\RustProjects\guessing_gamer> cargo update
    Updating crates.io index
PS C:\Users\xxsha\RustProjects\guessing_gamer> cargo clean
PS C:\Users\xxsha\RustProjects\guessing_gamer> cargo build
   Compiling guessing_gamer v0.1.0 (C:\Users\xxsha\RustProjects\guessing_gamer)
    Finished dev [unoptimized + debuginfo] target(s) in 0.22s
PS C:\Users\xxsha\RustProjects\guessing_gamer> cargo add irust
    Updating crates.io index
      Adding irust v1.71.4 to dependencies.
    Updating crates.io index
PS C:\Users\xxsha\RustProjects\guessing_gamer> cargo build
warning: guessing_gamer v0.1.0 (C:\Users\xxsha\RustProjects\guessing_gamer) ignoring invalid dependency `irust` which is missing a lib target
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s

I have also tried changing Cargo.toml to:

irust = { git = "https://github.com/sigmaSd/IRust" }

as well as:

irust = { git = "https://github.com/sigmaSd/IRust.git" }

Any help or clues in the right direction is appreciated thank you all.

Your dependency irust is a binary (executable) crate, not a library. You can't use it as a dependency. It's a stand-alone command that you have to install with cargo install irust, as its own documentation very clearly states.

2 Likes

https://crates.io/crates/irust gives the exact command "cargo add irust" which then adds to dependency section. I will try your suggestion thank you!


This looks like cargo install to me.

1 Like

It's unfortunate that there is currently no warning when adding binary packages with cargo add.

I think OP is referring to that little Install section automatically added by crates.io right beneath the Metadata, which states that you can install it with cargo add irust. This is a known issue for binary crates.

4 Likes