Crates rename doesn't work with features (`package = ...`)
mexus opened this issue · comments
Hi and thanks for the great custom registry! :)
I've come over an issue that i don't know how to handle: it's impossible to use a crate that renames a crate and uses it as a feature.
Step to reproduce:
- Create two crates:
$ cargo init --lib test-crate
and$ cargo init --lib use-test-crate
. - Set up the
test-crate
(test-crate/Cargo.toml
):
[package]
name = "test-crate"
version = "0.1.0"
authors = []
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
with = [ "bit-vec6" ]
[dependencies]
bit-vec6 = { version = "0.6", package = "bit-vec" }
- Set up the
use-test-crate
(use-test-crate/Cargo.toml
):
[package]
name = "use-test-crate"
version = "0.1.0"
authors = []
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
test-crate = { version = "0.1.0", registry = "REGISTRY-NAME"}
- Publish the
test-crate
:$ cd test-crate && cargo publish --registry REGISTRY-NAME
- Try to build the
use-test-crate
:$ cd use-test-crate && cargo check
Updating `ssh://git@..../crates-index.git` index
error: no matching package named `test-crate` found
location searched: registry `ssh://git@.../crates-index.git`
required by package `use-test-crate v0.1.0 (/home/mexus/test/rust/use-test-crate)`
cargo search
however returns the expected results though:
$ cargo search --registry REGISTRY-NAME test-crate
test-crate = "0.1.0" #
Any ideas how to fix the issue? :)
Forgot to mention, I use the latest version https://github.com/mcorbin/meuse/releases/tag/v1.1.2
Hello,
I can reproduce the issue.
it's weird because everything works as expected if I remove the feature
in the first lib. It seems cargo is unable to find the version if there is a feature in it.
I will investigate more this evening.
Cargo first looks at the registry index (the git repository), and only after Meuse is reached to download the dep. Here, Cargo fails to find the crate in the index, which is weird because it exists (and as I said, without features it works).
Maybe I made a mistake in the index json format.
I compared almost the same packages on crates.io index and on our private registry index and I guess I found out what's the issue:
on "meuse"
{
"features":[
],
"package":"bit-vec6",
"name":"bit-vec",
"registry":"https://github.com/rust-lang/crates.io-index",
"req":"^0.6",
"optional":true,
"kind":"normal",
"target":null,
"default_features":true
},
on "crates.io"
{
"name":"bit-vec6",
"req":"^0.6",
"features":[
],
"optional":true,
"default_features":true,
"target":null,
"kind":"normal",
"package":"bit-vec"
},
So I guess meuse swaps "name" and "package"..
Thank you for your investigations, I will reread the doc/RFC and fix that this evening (it should not be difficult to fix).
Thanks!
Unfortunately I'm not familiar with clojure so I'm not able to make a fix and test it.. but if you could point me at the place where I can swap the things I will happily test if it helps :)
it's somewhere in https://github.com/mcorbin/meuse/blob/master/src/meuse/crate.clj#L27
The rename-keys
part is wrong I think, but I did that a long time ago so I have to reread https://doc.rust-lang.org/cargo/reference/registries.html and https://github.com/rust-lang/rfcs/blob/master/text/2141-alternative-registries.md.
In the meantime you can also maybe update your git index manually with the right values if you need a quick fix for today.
In the meantime you can also maybe update your git index manually with the right values if you need a quick fix for today.
Somehow I've missed this straightforward opportunity %) will give it a try, thanks
Swapping "name"
and "package"
helped. Thanks again for a really fast response @mcorbin , will be waiting for a patch then!
I created a new release which should solve the issue.
This release contains a small breaking change on the /metrics
endpoint (I added more metrics but also renamed some). I will do an article describing all the changes for the release later tomorrow or thursday.