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

Cyclic dependencies prevent rust-analyzer from running properly #3390

Closed
rakanalh opened this issue Mar 1, 2020 · 10 comments
Closed

Cyclic dependencies prevent rust-analyzer from running properly #3390

rakanalh opened this issue Mar 1, 2020 · 10 comments

Comments

@rakanalh
Copy link

rakanalh commented Mar 1, 2020

Follow up to the discussion that happened here:
emacs-lsp/lsp-mode#1467

Emacs lsp-mode was reporting that rust-analyzer was not running although it was. At least, according to the ps aux | grep rust-analyzer it was indeed the case. However, rust-analyzer was not providing lsp-mode with the responses it expected.

Running rust-analyzer apparently on a large project such as substrate, it was noted that the rust-analyzer logs where as follows:

[ERROR ra_project_model] cyclic dependency pallet-babe -> substrate-test-runtime
[ERROR ra_project_model] cyclic dependency sc-executor -> substrate-test-runtime
[ERROR ra_project_model] cyclic dependency pallet-transaction-payment -> pallet-balances
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-io
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-runtime-interface-test-wasm
[ERROR ra_project_model] cyclic dependency frame-support -> frame-system
[ERROR ra_project_model] cyclic dependency sp-core -> sp-runtime-interface
[ERROR ra_project_model] cyclic dependency node-testing -> node-executor
[ERROR ra_project_model] cyclic dependency substrate-test-runtime-client -> sc-client
[ERROR ra_project_model] cyclic dependency substrate-test-runtime-client -> substrate-test-client
[ERROR ra_project_model] cyclic dependency substrate-test-runtime-client -> substrate-test-runtime

Although LSP reported that rust-analyzer was "initialized successfully", no service was provided by lsp mode whether that was goto-definition or autocompletion.

Note: I made sure i compiled and tested the latest master(commit: ea67e23 )

@flodiebold
Copy link
Member

One thing that might be helpful would be to run rust-analyzer analysis-stats . on the repository.

@matklad
Copy link
Member

matklad commented Mar 2, 2020

I think that's a known issue: when we lower cargo metadata to crate graph, we don't really make a distinction between a lib with cfg(test) and a lib without, we just forcefully enable test. However, cargo allows a test lib to depend on non-test lib

@rakanalh
Copy link
Author

rakanalh commented Mar 2, 2020

rust-analyzer analysis-stats . got stuck

✗ rust-analyzer analysis-stats .
[ERROR ra_project_model] cyclic dependency node-executor -> node-testing
[ERROR ra_project_model] cyclic dependency frame-system -> frame-support
[ERROR ra_project_model] cyclic dependency sc-executor -> substrate-test-runtime
[ERROR ra_project_model] cyclic dependency pallet-babe -> substrate-test-runtime
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-core
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-io
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-runtime-interface-test-wasm
[ERROR ra_project_model] cyclic dependency sp-state-machine -> sp-core
[ERROR ra_project_model] cyclic dependency sp-state-machine -> sp-trie
[ERROR ra_project_model] cyclic dependency substrate-test-runtime-client -> sc-client
[ERROR ra_project_model] cyclic dependency substrate-test-runtime-client -> substrate-test-client
[ERROR ra_project_model] cyclic dependency substrate-test-runtime-client -> substrate-test-runtime
[ERROR ra_project_model] cyclic dependency pallet-balances -> pallet-transaction-payment
Database loaded, 771 roots, 2.042732236s
Crates in this dir: 213
Total modules found: 945
Total declarations: 19870
Total functions: 11732
Item Collection: 51.508743797s, 0b allocated 0b resident
440/11732 3% processing: tests::rewards_should_work

For like 15 minutes, still running.

@bkchr
Copy link
Contributor

bkchr commented Mar 8, 2020

I'm using rust-analyzer with Substrate and it works without any problems. The cylic-dependency can be ignored. It does not prevents anything.

@rakanalh
Copy link
Author

rakanalh commented Mar 8, 2020

Compiling the more recent rust-analyzer versions basically resulted in the problem going away for me as well.
Closing the issue.

@rakanalh rakanalh closed this as completed Mar 8, 2020
@mTsBucy1
Copy link

When used in VSCode, having the cyclic dev dependency prevents ctrl-clicking to jump to the implementation, but no error shows up.

@mimoo
Copy link

mimoo commented Sep 12, 2023

I've had lots of problems with rust-analyzer in the last 6 months and I think it's also due to cyclic dependencies

@peterblockman
Copy link

When used in VSCode, having the cyclic dev dependency prevents ctrl-clicking to jump to the implementation, but no error shows up.

It still prevents ctrl + click in v0.3.1823. I am using VsCode Version: 1.85.2 (Universal).

@irvingoujAtDevolution
Copy link

Still have prevents go to reference with version v0.4.1952

@Veykril
Copy link
Member

Veykril commented May 8, 2024

For people stumbling over this, #14167 is the tracking issue for this

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

9 participants