-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Problem
I have two cargo projects, lets call them "the_bin" and "rename_deps".
"rename_deps" has a renamed dependency:
# rename_deps/Cargo.toml
[package]
name = "rename_deps"
version = "0.1.2"
edition = "2021"
publish = ["gitea"]
[dependencies]
embedded-hal-0-2 = { package = "embedded-hal", version = "0.2.7" }
// rename_deps/src/lib.rs
pub fn foo(_x: impl embedded_hal_0_2::PwmPin) { // <-- Using the renamed name here
todo!()
}
This is then what gets published to my private registry
[package]
edition = "2021"
name = "rename_deps"
version = "0.1.2"
publish = ["gitea"]
[dependencies.embedded-hal-0-2]
version = "0.2.7"
package = "embedded-hal"
Compiling this works fine. I have then published this to my own private cargo registry(gitea). The publish check thing passes with no errors.
I then create a new binary project "the_bin", add "rename_deps" as dependency. And now cargo build fails to compile "rename_deps" when running cargo build
on "the_bin". Same thing but with rename_deps { path = "some-path" }
or git =
and it compiles fine again.
Compiling rename_deps v0.1.2 (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.2/src/lib.rs:2:21
|
2 | pub fn foo(_x: impl embedded_hal_0_2::PwmPin) {
| ^^^^^^^^^^^^^^^^ use of undeclared crate or module `embedded_hal_0_2`
|
help: there is a crate or module with a similar name
|
2 | pub fn foo(_x: impl embedded_hal::PwmPin) {
| ~~~~~~~~~~~~
For more information about this error, try `rustc --explain E0433`.
error: could not compile `rename_deps` (lib) due to 1 previous error
Steps
- cargo new rename_deps --lib
- Add renamed dependency
- Use renamed dependency in rename_deps's code
- cargo publish
- cargo new the_bin
- cargo add rename_deps
- cargo build
- Boom - Fails to build rename_deps
Possible Solution(s)
Since what I receive from my registry seems correct this is likely not due to me using a private registry I think?
Notes
This is what gets published to my private registry (ignoring the comments)
[package]
edition = "2021"
name = "rename_deps"
version = "0.1.2"
publish = ["gitea"]
[dependencies.embedded-hal-0-2]
version = "0.2.7"
package = "embedded-hal"
Version
cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Manjaro 24.0.2 (Wynsdey) [64-bit]