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

Unresolved import only in lib.rs, but not main.rs - circular dev dependency failure #9574

Closed
jkelleyrtp opened this issue Jul 11, 2021 · 5 comments
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@jkelleyrtp
Copy link

jkelleyrtp commented Jul 11, 2021

I'm trying to import a crate from the same workspace and the import fails in the lib.rs file but not the main.rs file. I can't seem to fix the issue, IE cargo clean doesn't fix it, and the issue persists between restarts.

My Cargo.toml:

[package]
name = "dioxus-hooks"
version = "0.0.0"
edition = "2018"

[dependencies]
dioxus-core = { path = "../core"}

And the issues side-by-side

Screen Shot 2021-07-11 at 6 31 22 PM

Any idea on how the bust the cache to get RA working again?

@jkelleyrtp
Copy link
Author

Ah, I use this crate is a dev-dependency in my "core" crate - when I remove this RA is happy again. I guess there's an issue with circular dependencies through dev-dependencies.

@jkelleyrtp jkelleyrtp changed the title Unresolved import only in lib.rs, but not main.rs Unresolved import only in lib.rs, but not main.rs - circular dev dependency failure Jul 11, 2021
@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Jul 12, 2021
@sbzi1020
Copy link

You should try to update the rustc to the latest version. I had the same problem before, but after I upgrade the rustc and it fixed.

@Edgeworth
Copy link

This still happens for me, on rust version 1.61.0-nightly (10913c000 2022-03-03) and rust-analyzer vscode extension version: 9d473a0 2022-03-04 nightly.

@jiangying000
Copy link

still happens at rust-analyzer version: 1.65.0-nightly (015a824 2022-08-22)

I guess this affects wide range of projects, wish it be fixed some time.

Liamolucko added a commit to Liamolucko/rust-analyzer that referenced this issue Feb 16, 2023
Fixes rust-lang#9574
Fixes rust-lang#11410

`rust-analyzer` already counts all of the different targets of a crate as different crates, so it was pretty easy to just exclude dev dependencies from the dependency lists of the targets other than test, dev and bench when ingesting `cargo metadata`'s output. A similar thing is already done for build dependencies.

It's possible there might be something I'm missing here, since this is quite a long-standing issue which I expected to be much more complicated to solve; but, this seems to work. The circular dependency errors that `rust-analyzer` used to throw on `wasm-bindgen` went away after switching to this patched version.
@Veykril
Copy link
Member

Veykril commented Feb 16, 2023

Closing in favor of #14167

@Veykril Veykril closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants