Skip to content

Add warning about rust-analyzer not working if you clone and use the repo directly - #2131

Closed
MadLittleMods wants to merge 6 commits into
rust-lang:mainfrom
MadLittleMods:madlittlemods/repo-clone-rust-analyzer-not-working-warning
Closed

Add warning about rust-analyzer not working if you clone and use the repo directly#2131
MadLittleMods wants to merge 6 commits into
rust-lang:mainfrom
MadLittleMods:madlittlemods/repo-clone-rust-analyzer-not-working-warning

Conversation

@MadLittleMods

@MadLittleMods MadLittleMods commented Oct 14, 2024

Copy link
Copy Markdown

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 running rustlings init. No repo cloning happens. Instead, the directory rustlings/ 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, #1935 (comment)

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.

  1. Clone the repo: git clone git@github.com:rust-lang/rustlings.git
  2. Start Rustlings: cargo run
  3. Open VSCode and notice that rust-analyzer and lsp hints don't pop up
  4. Google and find StackOverflow answers that mention rustlings lsp to setup lsp support
  5. But rustlings lsp doesn't exist anymore and the changelog mentions that it should be supported out of the box. It's also confusing because the rustlings repo has it's own Cargo.toml with include = [... "/exercises/", ...] which to my newbie Rust eyes, seems like it might cover it and makes me think, this is supposed to work.
  6. Eventually, I saw Use Cargo.toml instead of rust-project.json #1935 linked somewhere and it mentions this exact problem

Dev notes

…e 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 running `rustlings init`. No repo cloning happens. Instead, the directory `rustlings/` 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, rust-lang#1935 (comment)

Other references:

 - Previous `rustlings lsp` command: rust-lang#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
@mo8it

mo8it commented Oct 16, 2024

Copy link
Copy Markdown
Contributor

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."

Comment thread README.md Outdated

</details>

> [!CAUTION]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used caution but feel free to nit to warning or any other.

Comment thread README.md Outdated
</details>

> [!CAUTION]
> 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.

@MadLittleMods MadLittleMods Oct 16, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to your exact wording ✅

I've kept the extra "Why?" background in a collapsible section since it feels like it adds a little bit of something that makes it more understandable and convincing. Happy to remove to get this shipped if you prefer.

@hongkheng

Copy link
Copy Markdown

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.

@mo8it

mo8it commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

I don't think that this is needed anymore. Cloning is deprecated for a while now.

@mo8it mo8it closed this Apr 2, 2026
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.

3 participants