How to make rust-analyzer run in root mode?

In my code, some operations need root permission, and the analyzer in vscode gives the warning:

[ERROR rust_analyzer::main_loop] FetchBuildDataError:

 Caused by:
  Permission denied (os error 13)

which results in that I cannot have the complete functionalities of rust-analyzer, how do I should do to resolve this problem?

That is not your code erroring. Is your ~/.cargo directory or any subdirectory or file within it owned by root by any chance? Cargo and rust-analyzer should never be run as root. Instead you should do cargo build and then run the build output as root yourself.


My system is macOS, and ls seems cannot work to list all privileges the directories have. The rust-analyzer tries to build the code and causes the permission error, which interrupts the type prompt in the vscode.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.