Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crates rename doesn't work with features (package = ...) #36

Closed
mexus opened this issue Feb 9, 2021 · 10 comments
Closed

Crates rename doesn't work with features (package = ...) #36

mexus opened this issue Feb 9, 2021 · 10 comments

Comments

@mexus
Copy link

mexus commented Feb 9, 2021

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:

  1. Create two crates: $ cargo init --lib test-crate and $ cargo init --lib use-test-crate.
  2. 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" }
  1. 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"}
  1. Publish the test-crate: $ cd test-crate && cargo publish --registry REGISTRY-NAME
  2. 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? :)

@mexus
Copy link
Author

mexus commented Feb 9, 2021

Forgot to mention, I use the latest version https://github.com/mcorbin/meuse/releases/tag/v1.1.2

@mcorbin
Copy link
Owner

mcorbin commented Feb 9, 2021

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.

@mcorbin
Copy link
Owner

mcorbin commented Feb 9, 2021

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.

@mexus
Copy link
Author

mexus commented Feb 9, 2021

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"..

@mcorbin
Copy link
Owner

mcorbin commented Feb 9, 2021

Thank you for your investigations, I will reread the doc/RFC and fix that this evening (it should not be difficult to fix).

@mexus
Copy link
Author

mexus commented Feb 9, 2021

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 :)

@mcorbin
Copy link
Owner

mcorbin commented Feb 9, 2021

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.

@mexus
Copy link
Author

mexus commented Feb 9, 2021

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

@mexus
Copy link
Author

mexus commented Feb 9, 2021

Swapping "name" and "package" helped. Thanks again for a really fast response @mcorbin , will be waiting for a patch then!

@mcorbin mcorbin closed this as completed in 9f10885 Feb 9, 2021
@mcorbin
Copy link
Owner

mcorbin commented Feb 9, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants