I have a project in the form of a Rust workspace with a dozen of crates, including only one binary crate, that I want to publish on crates.io.
I'd like to not publish the library crates that are only here as an attempt to separate concerns and shorten build times, so they are not really thought to be reused outside of my project, but right now I'm struggling to get the result I want and just publish the binary crate.
For now my main attempt has been to add this to the workspace's Cargo.toml
:
[[bin]]
name = "my_project_binary_name"
path = "my_project_binary_name/src/main.rs"
But what I get this error message from cargo publish --dry-run
from the root of my workspace :
error: couldn't read my_project_binary_name/src/main.rs: No such file or directory (os error 2)
error: could not compile `my_project_binary_name` (bin "my_project_binary_name") due to previous error
Although obviously, the file exists.
I also tried, on top of that, to add the following to the Cargo.toml
of my binary crate :
[[bin]]
name = "my_project_binary_name"
path = "src/main.rs"
And call cargo publish like following :
❯ cargo publish --dry-run --verbose --allow-dirty -p my_project_binary_name
But I get the following error message :
error: failed to prepare local package for uploading
Caused by:
no matching package named `abstract_frontend` found
location searched: registry `crates-io`
Where "abstract_frontend" is one of the library crates of my workspace. I'm afraid I'm missing how to tell cargo to look locally, even though in my binary crate's Manifest, the dependency is explicitly defined through a relative path.
Am I missing something or is what I want to do infeasible ?