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

fix(rust-analyzer): don't run cargo if Cargo.toml is not found #2905

Merged
merged 1 commit into from
Nov 19, 2023
Merged

fix(rust-analyzer): don't run cargo if Cargo.toml is not found #2905

merged 1 commit into from
Nov 19, 2023

Conversation

kitterion
Copy link
Contributor

After commit d5d7412 I started getting the message

[lspconfig] cmd failed with code 101: table: 0x0104f90fe0
error: could not find `Cargo.toml` in `<path>` or any parent directory
Press ENTER or type command to continue

every time I open a rust file in a project that doesn't use cargo. For some reason cargo is launched even if Cargo.toml is not found which seems wrong, so I moved all the cargo logic inside if cargo_crate_dir ~= nil.
rust-analyzer supports non-cargo projects via rust-project.json that nvim-lspconfig also supports, and it's what I use.

@glepnir
Copy link
Member

glepnir commented Nov 19, 2023

i don't think this is correct. This command is still available when cargo_crate_dir does not exist. Try running this command cargo metadata --no-deps --format-version=1

@kitterion
Copy link
Contributor Author

I get the exact same error because there's no Cargo.toml

$ cargo metadata --no-deps --format-version=1
error: could not find `Cargo.toml` in `<path>` or any parent directory

@glepnir
Copy link
Member

glepnir commented Nov 19, 2023

okay.. command must run with cargo.toml. thanks.

@glepnir glepnir merged commit 6516abf into neovim:master Nov 19, 2023
9 checks passed
@kitterion kitterion deleted the do-not-run-cargo-without-cargo-toml branch November 19, 2023 07:33
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

Successfully merging this pull request may close these issues.

2 participants