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

Hanging on "Roots scanned" in Neovim but not vscode #12613

Closed
jrmoulton opened this issue Jun 22, 2022 · 9 comments
Closed

Hanging on "Roots scanned" in Neovim but not vscode #12613

jrmoulton opened this issue Jun 22, 2022 · 9 comments
Labels
C-support Category: support questions

Comments

@jrmoulton
Copy link

rust-analyzer ad6810e 2022-06-08 dev

rustc 1.63.0-nightly (b2eed72a6 2022-05-22)

I'm running rust analyzer inside of neovim and I am getting an issue similar to #8161 where rust analyzer is hanging on "Roots Scanned". This happens inside of neovim but it doesn't happen when I open the project inside of VSCode.

This also doesn't happen inside of most of my rust projects. It's happening using the esp-idf-template for an embedded project.
I've gone through the troubleshooting guide but I haven't found any more useful information. Any other tips on how else can I debug what is going on here?

@flodiebold flodiebold added the C-support Category: support questions label Jun 22, 2022
@andoriyu
Copy link

Happens on a very small project as well. (well, tokio + axum, but basic otherwise) Are you on M1 mac by any chance? I had no issues on linux with this before.

@jrmoulton
Copy link
Author

@andoriyu I am on an M1 mac

@andoriyu
Copy link

andoriyu commented Jul 4, 2022

@andoriyu I am on an M1 mac

If you open RA process in activity monitor you will see which files it's scanning. It's not stuck, it's just very slow.

I had to change RA config to explicitly exclude certain directories for it to stop doing that by adding dirs to rust-analyzer.files.excludeDirs.

Folder in my case was .direnv and was scanning entire nixpkgs repository.

@jrmoulton
Copy link
Author

Ahhh yeah that is whats happening. Ok I should be able to figure it out then. Thanks!

@yanshay
Copy link

yanshay commented Nov 3, 2023

I face the same issues with Neovim and esp-idf projects. Roots scanned never ends. I couldn't figure out how to solve this.
Any solutions?

@SethFalco
Copy link

I had to change RA config to explicitly exclude certain directories for it to stop doing that by adding dirs to rust-analyzer.files.excludeDirs.

I had a similar issue while trying to set up development for GNOME Fractal in Visual Studio Code.

Configuring rust-analyzer.files.excludeDirs was the solution for me, which I wrote the following config:

{
  "files.watcherExclude": {
    "**/_build": true,
    "**/.classpath": true,
    "**/.dart_tool": true,
    "**/.factorypath": true,
    "**/.flatpak-builder": true,
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/.idea": true,
    "**/.project": true,
    "**/.scannerwork": true,
    "**/.settings": true,
    "**/.venv": true,
    "**/node_modules": true
  },
  "rust-analyzer.files.excludeDirs": [
    "_build",
    ".dart_tool",
    ".flatpak-builder",
    ".git",
    ".gitlab",
    ".gitlab-ci",
    ".gradle",
    ".idea",
    ".next",
    ".project",
    ".scannerwork",
    ".settings",
    ".venv",
    "archetype-resources",
    "bin",
    "hooks",
    "node_modules",
    "po",
    "screenshots",
    "target"
  ]
}

9999years added a commit to 9999years/rust-analyzer that referenced this issue Jan 4, 2024
9999years added a commit to 9999years/rust-analyzer that referenced this issue Jan 9, 2024
bors added a commit that referenced this issue Jan 16, 2024
Show which roots are being scanned in progress messages

This changes the `Roots Scanned` message to include the directory being scanned.

Before: `Roots Scanned 206/210 (98%)`
After: `Roots Scanned 206/210: .direnv (98%)`

This makes it a lot easier to tell that `rust-analyzer` isn't crashed, it's just trying to scan a huge directory.

See: #12613
@GuillaumeLagrange
Copy link

GuillaumeLagrange commented Mar 22, 2024

Sorry to bother people on this old issue.

How would one identify files that are not excluded but should on linux (i.e the activity monitor from macOS is not available) ?

On a large repo, I am currently experiencing a ~3 seconds freeze in nvim but not in vscode
The only feedback I get is the number/progress of the scans (in my case 1k6+) from enabling debug logging in nvim.

EDIT: I just updated rust-analyzer and it now displays the directory being scanned, and I see nothing unexpected, it's just the repo being huge.

I think it's more a neovim issue than a rust analyzer issue.

@charypar
Copy link

charypar commented May 6, 2024

This may not be related, but just in case - I was seeing similar behaviour with rust-analyzer in NeoVim on macOS, and it was down to how the LSP configuration was constructed and an interaction betwen the recommended configuration of hrsh7th/cmp-nvim-lsp and RA's behaviour when file watching is not available (?).

Detailed report on a relevant issue in cmp-nvim-lsp, but the quick fix was to ensure workspace.didChangeWatchedFiles.dynamicRegistration was enabled. See the issue for config snippets.

@ulchie
Copy link

ulchie commented May 14, 2024

This may not be related, but just in case - I was seeing similar behaviour with rust-analyzer in NeoVim on macOS, and it was down to how the LSP configuration was constructed and an interaction betwen the recommended configuration of hrsh7th/cmp-nvim-lsp and RA's behaviour when file watching is not available (?).

Detailed report on a relevant issue in cmp-nvim-lsp, but the quick fix was to ensure workspace.didChangeWatchedFiles.dynamicRegistration was enabled. See the issue for config snippets.

Thank you so much for posting this! This just finally did it! I was getting so tired of using VSCode but my codebase was always stuck in Neovim until I enabled dynamicRegistration. I can't thank you enough for posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions
Projects
None yet
Development

No branches or pull requests

8 participants