Add warning about `rust-analyzer` not working if you clone and use the repo directly
Add warning about rust-analyzer not working if you clone and use the repo directly.
Yes, you are right, if you just clone the repository and try to edit the exercises, the language server will not work. This is one downside of the current approach. But this only affects developing exercises.
The new method of doing Rustlings is to install Rustlings using
cargo install rustlings(not published yet), then runningrustlings init. No repo cloning happens. Instead, the directoryrustlings/will be created where you find the exercises. The language server works there out of the box :)I need to add a warning when people try to work on the exercises from the repository. Thanks pointing this out.
-- @mo8it, https://github.com/rust-lang/rustlings/issues/1935#issuecomment-2067664066
Reproduction steps
Personally, I also fell into this trap since I would prefer to just run the thing from source than install something on my system.
- Clone the repo:
git clone [email protected]:rust-lang/rustlings.git - Start Rustlings:
cargo run - Open VSCode and notice that
rust-analyzerand lsp hints don't pop up - Google and find StackOverflow answers that mention
rustlings lspto setup lsp support - But
rustlings lspdoesn't exist anymore and the changelog mentions that it should be supported out of the box. It's also confusing because therustlingsrepo has it's ownCargo.tomlwithinclude = [... "/exercises/", ...]which to my newbie Rust eyes, seems like it might cover it and makes me think, this is supposed to work. - Eventually, I saw https://github.com/rust-lang/rustlings/issues/1935 linked somewhere and it mentions this exact problem
Dev notes
- Previous
rustlings lspcommand: https://github.com/rust-lang/rustlings/pull/1026 - The changelog says "LSP support out of the box", https://github.com/rust-lang/rustlings/blob/main/CHANGELOG.md#lsp-support-out-of-the-box
I agree that we should add something to the README for this, but the addition should tell people to not clone the repository and instead follow the instructions above. A simple warning should be enough. Something like this:
"Don't try to clone the repository to do the exercises! Rust-Analyzer won't work in that case. Please follow the instructions above instead."
Also facing this exact same issue. I wanted to be able to continue on the rustlings exercises over different laptops (work and personal) without having to restart from scratch. I ran cargo fix on the generated rustlings/ directory. And viola rust-analyzer was running in VSCode.