I have a Rust project that is simultaneously CLI and library with the project tree like this:
│ └── mybin.rs
I want to publish the library (not the CLI) to crates.io with
cargo publish, but I get this error
the remote server responded with an error:
invalid upload request: invalid value:
string "Rust cli and library project"
How can I publish only the library part of the project and not the CLI?
Publish works on entire packages (a
Cargo.toml defines a package). If you want to publish one and not the other, you will have to split your package into two packages (possibly in a workspace).
That said, the error you received sounds like you have a syntax error in your
Cargo.toml or something. What are the contents of your
Cargo.toml and what command did you run?
Thank you to lead me to inspect the Cargo.toml thoroughly.
The problem was in Cargo.toml "keywords".
I had spaces in the string and that is not allowed.
My content were:
keywords = ["Rust cli and library project"]
Note: crates.io has a maximum of 5 keywords.
Each keyword must be ASCII text, start with a letter,
and only contain letters, numbers, _ or -,
and have at most 20 characters.
After I corrected that, my publish was successful.
It is published as a library, not as a CLI.
Just as I wanted.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.