Attempt to decode a blank string
I followed the tutorial at https://sharksforarms.dev/posts/neovim-rust/ to set up a nvim environment for rust However, when I try to open an rust file in a directory contains Cargo.toml, it has following error:
Error detected while processing FileType Autocommands for "rust":
E5108: Error executing lua Vim:E474: Attempt to decode a blank string
stack traceback:
[C]: in function 'json_decode'
.../szx5097/.vim/plugged/rust-tools.nvim/lua/rust-tools.lua:176: in function 'get_root_dir'
...97/.vim/plugged/nvim-lspconfig/lua/lspconfig/configs.lua:232: in function 'try_add'
[string ":lua"]:1: in main chunk
Error detected while processing VimEnter Autocommands for "*.rs":
E5108: Error executing lua Vim:E474: Attempt to decode a blank string
stack traceback:
[C]: in function 'json_decode'
.../szx5097/.vim/plugged/rust-tools.nvim/lua/rust-tools.lua:176: in function 'get_root_dir'
.../szx5097/.vim/plugged/rust-tools.nvim/lua/rust-tools.lua:198: in function 'start_standalone_if_required'
[string ":lua"]:1: in main chunk
The command I used is nvim <project dir>/src/main.rs.
Does anyone know what is going on here? thanks!
It looks from the error that the Cargo.toml file wasn't in the correct place. Are you sure the project structure was correct with the Cargo.toml file in the same directory as the src/ directory?
If you've verified that that is correct I would recommend just starting with a basic rust-rools setup as outlined in this project's README. Also make sure that you have the latest version of the plugin and Rust Analyzer installed.