Skip to content

Instantly share code, notes, and snippets.

@jackos
Last active March 5, 2025 04:16
Show Gist options
  • Save jackos/7332fa8ab0b67a87f382fd566696f412 to your computer and use it in GitHub Desktop.
Save jackos/7332fa8ab0b67a87f382fd566696f412 to your computer and use it in GitHub Desktop.

Install rustlings-fix and run it:

cargo install rustlings-fix
rustlings-fix

For more information on how the file this generates works checkout the Rust Analyzer Manual

@crimx
Copy link

crimx commented Nov 29, 2022

worked like a charm!

@alex-way
Copy link

You are very sexy man

@jackos
Copy link
Author

jackos commented Mar 1, 2023

@alex-way haha thanks!

@Zolmok
Copy link

Zolmok commented Mar 31, 2023

Generating this file is now built into rustlings:
rustlings lsp

I just installed rustlings last night and this doesn't seem to be true. Have they removed this or has it just not made it in quite yet?

❯ rustlings lsp
Unrecognized argument: lsp

Run rustlings --help for more information.

❯ rustlings --help
Usage: rustlings [--nocapture] [-v] [<command>] [<args>]

Rustlings is a collection of small exercises to get you used to writing and reading Rust code

Options:
  --nocapture       show outputs from the test exercises
  -v, --version     show the executable version
  --help            display usage information

Commands:
  verify            Verifies all exercises according to the recommended order
  watch             Reruns `verify` when files were edited
  run               Runs/Tests a single exercise
  hint              Returns a hint for the given exercise
  list              Lists the exercises available in Rustlings

@jackos
Copy link
Author

jackos commented Mar 31, 2023

@Zolmok The version you installed must be older, uninstall it.

To get latest follow the commands in https://github.com/rust-lang/rustlings depending on OS:

Mac/Linux

curl -L https://raw.githubusercontent.com/rust-lang/rustlings/main/install.sh | bash

Windows

Open powershell as admin

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Start-BitsTransfer -Source https://raw.githubusercontent.com/rust-lang/rustlings/main/install.ps1 -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1

Which should give you:

❯ rustlings -v
v5.4.1

and:

❯ rustlings --help
...
Commands:
  verify            Verifies all exercises according to the recommended order
  watch             Reruns `verify` when files were edited
  run               Runs/Tests a single exercise
  reset             Resets a single exercise using "git stash -- <filename>"
  hint              Returns a hint for the given exercise
  list              Lists the exercises available in Rustlings
  lsp               Enable rust-analyzer for exercises

@Zolmok
Copy link

Zolmok commented Mar 31, 2023

Very strange, I thought that's what I did. I did it again though and now I have the later version. One thing I changed is from stable to nightly. I wonder if that is the difference? At any rate I have the lsp version now, tyvm!

@jackos
Copy link
Author

jackos commented Apr 1, 2023

@Zolmok no problem happy it works!

@kilogold
Copy link

kilogold commented Jul 4, 2023

Absolute hero. <3

@bkwhite
Copy link

bkwhite commented Nov 16, 2023

so helpful!

@Palanikannan1437
Copy link

Soo nice!!!!!!!!!!!! Thanks so much for this @jackos 🫶

@lenaggar
Copy link

nice!
I was struggling with this on vscode on windows and this fixed it for me ❤️

Copy link

ghost commented Dec 23, 2024

rustlings lsp doesn't work with the latest rustlings:

$ /home/xxx/.cargo/bin/rustlings lsp
error: unrecognized subcommand 'lsp'

Usage: rustlings [OPTIONS] [COMMAND]

For more information, try '--help'.

$ /home/xxx/.cargo/bin/rustlings --version
rustlings 6.4.0

@jackos
Copy link
Author

jackos commented Mar 5, 2025

Thanks ghost they deleted it a while back for some reason, the old method still works:

cargo install rustlings-fix
rustlings-fix

Updated the gist above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment