Skip to content

Cyclic dependency detected when running analysis-stats on future-rs #2414

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

Closed
edwin0cheng opened this issue Nov 26, 2019 · 5 comments
Closed
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@edwin0cheng
Copy link
Member

edwin0cheng commented Nov 26, 2019

When running analysis-stats (4d753fa) on futures-rs:

C:\sandbox\rust-root\rust-analyzer (master -> origin)
λ cargo run --release -p ra_cli -- analysis-stats -q ..\futures-rs
    Finished release [optimized] target(s) in 1.33s
     Running `target\release\ra_cli.exe analysis-stats -q ..\futures-rs`
ERROR [ra_project_model] cyclic dependency futures -> futures-channel
ERROR [ra_project_model] cyclic dependency futures -> futures-core
ERROR [ra_project_model] cyclic dependency futures -> futures-task
ERROR [ra_project_model] cyclic dependency futures -> futures-test
ERROR [ra_project_model] cyclic dependency futures-util -> futures
ERROR [ra_project_model] cyclic dependency futures-util -> futures-channel
ERROR [ra_project_model] cyclic dependency futures-util -> futures-core
ERROR [ra_project_model] cyclic dependency futures-util -> futures-task
ERROR [ra_project_model] cyclic dependency futures-util -> futures-test
ERROR [ra_project_model] cyclic dependency futures-executor -> futures
ERROR [ra_project_model] cyclic dependency futures-executor -> futures-core
ERROR [ra_project_model] cyclic dependency futures-executor -> futures-task
Database loaded, 92 roots, 2.2761003s
Crates in this dir: 64
Total modules found: 304
Total declarations: 7893
Total functions: 1689
Item Collection: 7.6418828s, 0b allocated 0b resident
Total expressions: 40920
Expressions of unknown type: 5394 (13%)
Expressions of partially unknown type: 6398 (15%)
Type mismatches: 1824
Inference: 21.2589651s, 0b allocated 0b resident
Total: 28.9012308s, 0b allocated 0b resident
@edwin0cheng
Copy link
Member Author

edwin0cheng commented Dec 3, 2019

I think the reason of cycle dependencys is similar to rust-lang/cargo#4242

And see #1282

@matklad
Copy link
Member

matklad commented Dec 3, 2019

Yeah, the problem is that a crate can have a dev-dep onto itself:

[package]
name = "foo"
version = "0.1.0"
edition = "2018"

[dev-dependencies]
foo = { path = "." }

The solution here is to start "duplicating" crates when lowering cargo-metada output to CrateGraph. In the above example, we should construct two foo crates, one with cfg(test) and one without, and make the required depednency edge.

@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Dec 21, 2020
@djc
Copy link

djc commented Jan 20, 2021

I'm seeing something similar to this in Cargo, where cargo has a dev-dep on cargo-test-support while cargo-test-support depends on cargo.

[Error - 11:10:15 AM] Registering progress handler for token rustAnalyzer/fetching failed.
Error: Progress handler for token rustAnalyzer/fetching already registered
	at Object.onProgress (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:5366:23)
	at LanguageClient.onProgress (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:13386:45)
	at new ProgressPart (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:11405:41)
	at createHandler (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:14710:34)
	at handleRequest (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:4896:41)
	at processMessageQueue (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:4777:17)
	at Immediate._onImmediate (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:4767:13)
	at processImmediate (internal/timers.js:439:21)
[ERROR project_model::workspace] cyclic deps: cargo_test_support(CrateId(59)) -> cargo(CrateId(49))
[Error - 11:11:48 AM] Registering progress handler for token rustAnalyzer/fetching failed.
Error: Progress handler for token rustAnalyzer/fetching already registered
	at Object.onProgress (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:5366:23)
	at LanguageClient.onProgress (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:13386:45)
	at new ProgressPart (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:11405:41)
	at createHandler (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:14710:34)
	at handleRequest (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:4896:41)
	at processMessageQueue (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:4777:17)
	at Immediate._onImmediate (/Users/djc/.vscode/extensions/matklad.rust-analyzer-0.3.446-nightly/out/src/main.js:4767:13)
	at processImmediate (internal/timers.js:439:21)

@KalitaAlexey
Copy link

We see this issue because our packages have [dev-dependencies] on each other. Does it break anything?

@Veykril
Copy link
Member

Veykril commented Feb 16, 2023

Closing in favor of #14167

@Veykril Veykril closed this as completed Feb 16, 2023
Liamolucko added a commit to Liamolucko/rust-analyzer that referenced this issue Feb 17, 2023
I also had to change the logic for whether they get put into test mode or not:
* Bin crates now only get put into test mode if they're a part of the current workspace, because otherwise dev dependencies don't work
    * this didn't actually change anything because bin crates outside the current workspace are already ignored but idk it's better to make it explicit?
* The version of a lib crate with test mode enabled is now separate from the normal version of the lib crate, since it's allowed to depend on the normal version as a dev dependency.
  (as suggested in rust-lang#2414 (comment))
* The test-mode version of the lib crate is also only created if it's a part of the current workspace.
hrxi added a commit to nimiq/core-rs-albatross that referenced this issue Mar 16, 2023
jsdanielh pushed a commit to nimiq/core-rs-albatross that referenced this issue Mar 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

No branches or pull requests

6 participants