Description
If I do cargo publish --help
, I see this documentation for the --host
flag:
--host HOST Host to upload the package to
If I wanted to upload to the staging instance of crates.io at https://staging-crates-io.herokuapp.com/, the name of this flag and the docs make me think I should specify --host staging-crates-io.herokuapp.com
here. This does not publish to the staging instance, however.
By digging into the code, I've figured out that what this flag actually wants is the location of the index to which I want to publish:
- In the publish binary,
host
gets used in thePublishOpts.index
field - This code calls
index.to_url()
, which means it doesn't just want a host, it wants something that parses as a valid URL - The URL eventually gets used as a git index, and the config.json file gets read to extract the api_host.
When I'm running crates.io locally, i'm able to publish to my local instance by giving cargo --host=file:///path/to/crates.io/tmp/index-co/
. I'm able to get to a sort-of-working point with staging crates.io by specifying --host=https://github.com/alexcrichton/cargo-registry-index
.
So I think that --host
should be renamed to --index-url
, or at the very least, the documentation in all the commands that use --host
should explain that it should be a URL to the index you want to publish to.