Hi!
Sorry if this has been answered before but I really could not find anything.
I have two cargo projects, lets call them "the_bin" and "rename_deps".
"rename_deps" has dependencies on multipel versions of the same crate,
embedded-hal v0.2 and optionally embedded-hal v1 (1.0.0-alpha.9 in this case, have not yet updated, but that is beside the point).
[package]
name = "rename_deps"
version = "0.1.0"
edition = "2021"
publish = ["gitea"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
e-hal-v1 = ["embedded-hal"]
[dependencies]
embedded-hal = { version = "=1.0.0-alpha.9", optional = true }
embedded-hal-0-2 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"] }
src/lib.rs
pub fn do_things_w_v02_input(_x: impl embedded_hal_0_2::digital::v2::InputPin){ todo!() }
// Not used
#[cfg(feature = "e-hal-v1")]
pub fn do_things_w_v1_input(_x: impl embedded_hal::digital::InputPin){ todo!() }
Compiling "rename_deps" works fine. cargo c && argo c --all-features
completes successfully.
I create my new project "the_bin" which depends on "rename_deps" with default features (not embedded-hal v1) and directly on embedded-hal v0.2:
[package]
name = "the_bin"
version = "0.1.0"
edition = "2021"
[dependencies]
rename_deps = { path = "local path" } # <--- This is a local path on my machine
#rename_deps = { version = "0.1.0", registry = "gitea" } # <-- Not yet
embedded-hal = { package = "embedded-hal", version = "0.2.7" }
This too works fine. (notice the local path to "rename_deps".
I then publish this crate to my private registry(gitea), the pre-publish check-thing succeeds and all is fine. Then after
updating the dependency in Cargo.toml to:
rename_deps = { version = "0.1.0", registry = "gitea" }
it won't compile:
Downloaded rename_deps v0.1.0 (registry `gitea`)
Downloaded 1 crate (1.0 KB) in 0.17s
Compiling rename_deps v0.1.0 (registry `gitea`)
error[E0433]: failed to resolve: use of undeclared crate or module `embedded_hal_0_2`
--> /home/albin/.cargo/registry/src/my-very-secret-gitea-registry/rename_deps-0.1.0/src/lib.rs:2:39
|
2 | pub fn do_things_w_v02_input(_x: impl embedded_hal_0_2::digital::v2::InputPin){
| ^^^^^^^^^^^^^^^^ use of undeclared crate or module `embedded_hal_0_2`
|
help: there is a crate or module with a similar name
|
2 | pub fn do_things_w_v02_input(_x: impl embedded_hal::digital::v2::InputPin){
| ~~~~~~~~~~~~
help: consider importing this module
|
2 + use embedded_hal::digital::v2;
|
help: if you import `v2`, refer to it directly
|
2 - pub fn do_things_w_v02_input(_x: impl embedded_hal_0_2::digital::v2::InputPin){
2 + pub fn do_things_w_v02_input(_x: impl v2::InputPin){
|
For more information about this error, try `rustc --explain E0433`.
error: could not compile `rename_deps` (lib) due to previous error
for some reason "rename_deps" fails to compile, the renamed dep: embedded_hal_0_2
can not be found.
Am I doing anything wrong ? Is this a rust issue or should I post this question at gitea the service I use for my private registry. I am fine with sharing this code if it helps
I could publish rename_deps
to the regular crates.io just to test but that feels a bit wasteful for a test.
/Albin