Search code examples
rustrust-cargo

How to run commands from a cargo crate?


I was trying to use the git-ignore-generator crate to manage .gitignore more easily, but now I am stuck as I have added the crate by cargo add and can not use the commands the crate documentation refers to. I have also tried to run cargo and just got a warning:

ignoring invalid dependency `git-ignore-generator` which is missing a lib target"

Here is my Cargo.toml file. What am I missing?


Solution

  • git-ignore-generator is not a library but a installable program. If you want to install it, you have to run cargo install instead of cargo add:

    cargo install git-ignore-generator
    

    And remove it from your Cargo.toml, it should not be there.