tazz4843 / coqui-stt

Safe wrapper around the Coqui STT C library
108 stars 9 forks source link

Can't install via `cargo install coqui-stt` #2

Closed JRMeyer closed 2 years ago

JRMeyer commented 2 years ago

Hi there @tazz4843 👋

forgive my Rust ignorance:)

I was hoping to have an easy install with cargo install, but I get this error:

$ cargo install coqui-stt
    Updating crates.io index
  Downloaded coqui-stt v0.2.1
  Downloaded 1 crate (15.0 KB) in 1.74s
error: there is nothing to install in `coqui-stt v0.2.1`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency in a Cargo project instead.

I see what the error message, and what little I've read says this could be used as a dependency.

If it would make sense, I think it would be a great dev experience to install via a package manager like cargo

thanks for open-sourcing this btw!

randomairborne commented 2 years ago

Cargo install is more akin to a package manager, you need to add it as a dependency in your project's Cargo.toml to use it in your project

JRMeyer commented 2 years ago

What would it take to make it installable via 'cargo install'? It seems the Dev experience would have less friction that way, no?

tazz4843 commented 2 years ago

Cargo.toml is the typical way of adding a new library dependency, and cargo install is just for executables, not for libraries.

From the Rust book (https://doc.rust-lang.org/book/ch14-04-installing-binaries.html):

The cargo install command allows you to install and use binary crates locally. This isn’t intended to replace system packages; it’s meant to be a convenient way for Rust developers to install tools that others have shared on crates.io. Note that you can only install packages that have binary targets. A binary target is the runnable program that is created if the crate has a src/main.rs file or another file specified as a binary, as opposed to a library target that isn’t runnable on its own but is suitable for including within other programs. Usually, crates have information in the README file about whether a crate is a library, has a binary target, or both.

And from https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html#using-a-crate-to-get-more-functionality:

Remember that a crate is a collection of Rust source code files. The project we’ve been building is a binary crate, which is an executable. The rand crate is a library crate, which contains code intended to be used in other programs, and can’t be executed on its own.

This crate (coqui-stt) and its FFI binding variant (coqui-stt-sys) both qualify as library crates that do nothing on their own.

However, there is a binary crate that adds cargo add, which would do exactly what you're trying to do, and it would add it to the current Rust project: https://github.com/killercup/cargo-edit

This turned into a bit of a wall of text, sorry about that :P

JRMeyer commented 2 years ago

Hi @tazz4843 -- the wall of text is super informative! thanks for taking the time to elaborate to me, a Rust noob 💚

I'll close this comment because you're already doing exactly what makes sense:)

Thanks again for open-sourcing this! Feel free to come chat in the 🐸STT chatrooms :D gitter.im/coqui-ai/STT