rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
53.76k stars 10.12k forks source link

v6 beta feedback 🥰 #1960

Closed mo8it closed 3 months ago

mo8it commented 6 months ago

After about a month of intensive work, I am happy announce the beta release of version 6 🎉

It is a full rewrite of the command line tool. Therefore, I hope to find some people willing to test it and provide some feedback here 🥰

You can try it by following the instructions in the README of the v6 branch. NOTE: You don't need to clone the Rustlings repository anymore.

Your feedback is welcome, as detailed as you want 🥰 But don't focus on the exercises. These didn't really change in v6.

Points to consider in the feedback

Known issues

mo8it commented 6 months ago

Pinging @orhun because you were willing to test it 🥰

norraell commented 6 months ago

Thanks for your efforts put into this!

I stumbled on an error while installing:

error: failed to compile `rustlings v6.0.0-beta.3`, intermediate artifacts can be found at `/var/folders/bc/g5l5nq855nd_fb3y1psnc6v00000gn/T/cargo-installsN59ZL`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Caused by:
  package `clap_lex v0.7.0` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.73.0

I fixed this issue by running rustup update. Maybe it's worth mentioning the minimal required Rust version (which seems to be 1.74) in the README?

mo8it commented 6 months ago

@norraell I will add a note about this to the README. Thanks :D

mo8it commented 6 months ago

@norraell The README is now updated to include rustup update as a troubleshooting step if the installation fails :D

orhun commented 6 months ago

Hello, thanks for the ping!

I got this error right off the bat:

Error: Failed to run the command `target/debug/intro1`

Caused by:
    No such file or directory (os error 2)

I'm assuming this is due to my custom cargo setup (global target directory):

[build]
target-dir = "/drv/cargo/target"

So rustlings probably shouldn't hardcode target and respect this config option and also CARGO_TARGET_DIR variable :bear:

mo8it commented 6 months ago

@orhun Thank you for reporting this issue 😅

Would it be fine if I create the file .cargo/config.toml with target-dir = "target" to override the global setting?

Otherwise, I would need to add the serde_json dependency and parse the JSON output of cargo metadata --no-deps --format-version 1 just to read the target_directory field. This would mean running that command and parsing its output at every startup… Because CARGO_TARGET_DIR is not a global environment variable.

orhun commented 6 months ago

Would it be fine if I create the file .cargo/config.toml with target-dir = "target" to override the global setting?

Don't think so, I think it would be best to not mess with the user's configuration.

Otherwise, I would need to add the serde_json dependency and parse the JSON output

Or you can simply read .cargo/config.toml and check if the target directory is being overriden. Checking the value of CARGO_TARGET_DIR at runtime would be fine also. So the correct logic should be:

What do you think?

mo8it commented 6 months ago

It is not that easy because Cargo looks for the config file in the current directory and all parent directories. You would also need to find out what $CARGO_HOME is. Sadly, we have platforms like Windows that we need to support 😅

I guess I will just parse that JSON then :P

orhun commented 6 months ago

It is not that easy because Cargo looks for the config file in the current directory and all parent directories.

Ouf, unfortunately I'm not aware of a crate that might help with that :/

dotjpg3141 commented 6 months ago

Feedback

Here is my feedback. I already know Rust, but I never looked at rustlings before. I hope this is not too detailed. 😅 I have written down everything I found while doing the exercises. I'm getting a little bit tired; hoping my ramblings make sense.

Here are my solutions for reference.

I'm using

1) rustlings watch doesn't work

From the rustlings command

Got all that? Great! To get started, run `rustlings watch` in order to get the first exercise.
Make sure to have your editor open in the `rustlings` directory!

When I run rustlings watch:

>rustlings watch
error: unrecognized subcommand 'watch'

Usage: rustlings [OPTIONS] [COMMAND]

For more information, try '--help'.

2) Encoding/Display error

Question Mark. Unicode Replacement Character? encoding

3) Invisible input text

invisible-input-text

Missing output when unit tests are failing

If unit tests are failing (e.g. assert_eq!(2 + 2, 5)), there is no output of the panic message. The only thing I see:

running 14 tests
test tests::test_array_correct ... ok
test tests::test_array_out_of_range_positive ... ok
test tests::test_array_sum ... ok
test tests::test_array_out_of_range_negative ... ok
test tests::test_slice_correct ... ok
test tests::test_slice_excess_length ... ok
test tests::test_slice_insufficient_length ... ok
test tests::test_slice_out_of_range_negative ... ok
test tests::test_tuple_out_of_range_positive ... ok
test tests::test_slice_out_of_range_positive ... ok
test tests::test_slice_sum ... ok
test tests::test_tuple_out_of_range_negative ... ok
test tests::test_tuple_sum ... ok
test tests::test_tuple_correct ... FAILED

failures:

failures:
    tests::test_tuple_correct

test result: FAILED. 13 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Output
Ok(Color { red: 183, green: 65, blue: 14 })
Ok(Color { red: 183, green: 65, blue: 14 })
Ok(Color { red: 183, green: 65, blue: 14 })
Ok(Color { red: 183, green: 65, blue: 14 })

4) Rust-Analyzer

Not all files with compile errors are highlighted by Rust Analyzer. Workarounds:

5) Quiz

exercises\quizzes\quiz3.rs was the first quiz I got after completing 15_traits. I neither got quiz1.rs nor quiz2.rs.

6) Progress bar

This is the output after I solved the exercises in order. Note: I didn't got to quiz1.rs or quiz2.rs.

Output
Hello and
       welcome to...
                 _   _ _
  _ __ _   _ ___| |_| (_)_ __   __ _ ___
 | '__| | | / __| __| | | '_ \ / _` / __|
 | |  | |_| \__ \ |_| | | | | | (_| \__ \
 |_|   \__,_|___/\__|_|_|_| |_|\__, |___/
                               |___/

This exercise compiles successfully. The remaining exercises contain a compiler
or logic error. The central concept behind Rustlings is to fix these errors and
solve the exercises. Good luck!

The file of this exercise is `exercises/00_intro/intro1.rs`. Have a look!
The current exercise path is shown under the progress bar in the watch mode.

Exercise done ✓
When you are done experimenting, enter `n` or `next` to go to the next exercise 🦀

A solution file can be found at solutions/00_intro/intro1.rs

Progress: [#######################################################################################################################################################################################>-----------------------]  85/96 exercises
Current exercise: exercises/00_intro/intro1.rs

7) Excercises

Nit: Wording

Especially in the first exercises, add a one-liner comment:

Here are some examples:

Nit: Sort Order

Nit: Clippy/Compiler Warnings (Even After Solving the Exercise)

There are some compiler/clippy warnings that might be overwhelming at the start.

mo8it commented 6 months ago

Hi Jan @dotjpg3141, thank you very much for your very valuable detailed feedback. I can't express how much it means to me, thank you for your time 🤗🤗🤗

I will probably need days to fix all the issues that you mentioned and give you a detailed reply.

mo8it commented 6 months ago

@orhun Respecting the target-dir option is done by https://github.com/rust-lang/rustlings/commit/c82c3673245ca11d455b067c97fadda4a8406cb9. You can try the new beta version beta.4 :D

orhun commented 6 months ago

Now I'm getting this:

$ rustlings init

error: could not find `Cargo.toml` in `/tmp/tmp.N6HnsDD5Fw` or any parent directory
Error: Failed to read the field `target_directory` from the `cargo metadata` output

Caused by:
    EOF while parsing a value at line 1 column 0

I think it requires to be run in a Cargo project directory where Cargo.toml is present. Is that really needed for initialization?

mo8it commented 6 months ago

@orhun Oh well, this one is embarrassing… I shouldn't release anything that late in the night and should definitely add more tests. Anyway, it should work in beta.5 now 😅

orhun commented 6 months ago

No worries, all seems good now. I haven't tested the exercises but the the prompt/TUI is working smoothly for me. Great job!

I can look into this more in depth in the following days probably.

mo8it commented 6 months ago

@dotjpg3141

1) rustlings watch doesn't work

Fixed

2) Encoding/Display error

This is a problem with the used terminal (cmd.exe?). Users are supposed to use a modern terminal like the new Windows Terminal. I added a note to the README about the recommended terminal.

3) Invisible input text

This is very weird, but I hope that it doesn't happen in a modern terminal like Windows Terminal. Could you please try it out?

Missing output when unit tests are failing

Fixed

4) Rust-Analyzer

Not all files with compile errors are highlighted by Rust Analyzer. Workarounds:

* Save file (without changes)

* Reload VS Code

I am afraid that we can't do anything about this. The most important thing is that Rust-Analyzer provides autocompletion, goto definition, rename and so on. Warnings and errors are shown by Rustlings anyway.

5) Quiz

exercises\quizzes\quiz3.rs was the first quiz I got after completing 15_traits. I neither got quiz1.rs nor quiz2.rs.

6) Progress bar

This is the output after I solved the exercises in order. Note: I didn't got to quiz1.rs or quiz2.rs.

Output
Hello and
       welcome to...
                 _   _ _
  _ __ _   _ ___| |_| (_)_ __   __ _ ___
 | '__| | | / __| __| | | '_ \ / _` / __|
 | |  | |_| \__ \ |_| | | | | | (_| \__ \
 |_|   \__,_|___/\__|_|_|_| |_|\__, |___/
                               |___/

This exercise compiles successfully. The remaining exercises contain a compiler
or logic error. The central concept behind Rustlings is to fix these errors and
solve the exercises. Good luck!

The file of this exercise is `exercises/00_intro/intro1.rs`. Have a look!
The current exercise path is shown under the progress bar in the watch mode.

Exercise done ✓
When you are done experimenting, enter `n` or `next` to go to the next exercise 🦀

A solution file can be found at solutions/00_intro/intro1.rs

Progress: [#######################################################################################################################################################################################>-----------------------]  85/96 exercises
Current exercise: exercises/00_intro/intro1.rs

I tried to reproduce these two issues related to the order of exercises but I couldn't. What happens if you enter n when you see the above output? What happens when you restart Rustlings and then try to enter n?

Could you please post the content of the hidden file .rustlings-state.txt? A screenshot of all exercises in the list would be alse very helpful. You can open the list by entering l.


I will fix the things that you pointed out about the exercises and Clippy later. Thank you again for your very valuable feedback 🥰

vgroenewold commented 5 months ago

Love the new direction rustlings is taking! One issue I'm having: After starting rustlings, I get an "invalid argument" for running the intro1 command and rustlings exists.

dotjpg3141 commented 5 months ago

I used rustlings@6.0.0-beta.6

2) Encoding/Display error

This is a problem with the used terminal (exe.cmd?).

Yep. This seems to be an issue of cmd.

3) Invisible input text

This is very weird, but I hope that it doesn't happen in a modern terminal like Windows Terminal. Could you please try it out?

That doesn't seem to make a difference.

https://github.com/rust-lang/rustlings/assets/8530833/9dc7fab9-f372-4631-ac93-e3d62b40c46f

5) Quiz / 6) Progress bar

I tried to reproduce these two issues related to the order of exercises but I couldn't. What happens if you enter n when you see the above output? What happens when you restart Rustlings and then try to enter n?

Could you please post the content of the hidden file .rustlings-state.txt? A screenshot of all exercises in the list would be alse very helpful. You can open the list by entering l.

This is the content of `.rustlings-state.txt`. ``` DON'T EDIT THIS FILE! intro1 intro2 variables1 variables2 variables3 variables4 variables5 variables6 functions1 functions2 functions3 functions4 functions5 if1 if2 primitive_types1 primitive_types3 primitive_types4 primitive_types5 vecs1 vecs2 move_semantics1 move_semantics2 move_semantics3 move_semantics4 move_semantics5 move_semantics6 structs1 structs2 enums1 enums3 strings2 strings3 strings4 modules1 modules2 modules3 hashmaps1 hashmaps2 hashmaps3 options1 options2 options3 errors2 errors3 errors4 errors5 generics1 generics2 traits1 traits2 traits3 traits4 traits5 quiz3 lifetimes1 lifetimes2 lifetimes3 tests1 tests2 tests3 tests4 iterators1 iterators2 iterators3 iterators4 iterators5 box1 rc1 arc1 cow1 threads1 threads2 threads3 macros1 macros2 macros3 macros4 clippy1 clippy2 clippy3 using_as from_into from_str try_from_into as_ref_mut ```
Screenshots of the list. Page 1: ![list1](https://github.com/rust-lang/rustlings/assets/8530833/1409b4f6-afe2-469e-a217-2a52cf076b7c) Page 2: ![list2](https://github.com/rust-lang/rustlings/assets/8530833/cb74ef32-c698-4a88-85e3-55e528e10c51) Page 3 ![list3](https://github.com/rust-lang/rustlings/assets/8530833/051afe80-4b8d-48c6-9026-26392bcdb398) Only Pending: ![pending](https://github.com/rust-lang/rustlings/assets/8530833/75afb19b-3ec5-420f-b652-1f8dcaf97f48)
Text content of the list (without the `next` column). ``` State Name Path PENDING intro1 exercises/00_intro/intro1.rs DONE intro2 exercises/00_intro/intro2.rs DONE variables1 exercises/01_variables/variables1.rs DONE variables2 exercises/01_variables/variables2.rs DONE variables3 exercises/01_variables/variables3.rs DONE variables4 exercises/01_variables/variables4.rs DONE variables5 exercises/01_variables/variables5.rs DONE variables6 exercises/01_variables/variables6.rs DONE functions1 exercises/02_functions/functions1.rs DONE functions2 exercises/02_functions/functions2.rs DONE functions3 exercises/02_functions/functions3.rs DONE functions4 exercises/02_functions/functions4.rs DONE functions5 exercises/02_functions/functions5.rs DONE if1 exercises/03_if/if1.rs DONE if2 exercises/03_if/if2.rs PENDING if3 exercises/03_if/if3.rs PENDING quiz1 exercises/quizzes/quiz1.rs DONE primitive_types1 exercises/04_primitive_types/primitive_types1.rs PENDING primitive_types2 exercises/04_primitive_types/primitive_types2.rs DONE primitive_types3 exercises/04_primitive_types/primitive_types3.rs DONE primitive_types4 exercises/04_primitive_types/primitive_types4.rs DONE primitive_types5 exercises/04_primitive_types/primitive_types5.rs PENDING primitive_types6 exercises/04_primitive_types/primitive_types6.rs DONE vecs1 exercises/05_vecs/vecs1.rs DONE vecs2 exercises/05_vecs/vecs2.rs DONE move_semantics1 exercises/06_move_semantics/move_semantics1.rs DONE move_semantics2 exercises/06_move_semantics/move_semantics2.rs DONE move_semantics3 exercises/06_move_semantics/move_semantics3.rs DONE move_semantics4 exercises/06_move_semantics/move_semantics4.rs DONE move_semantics5 exercises/06_move_semantics/move_semantics5.rs DONE move_semantics6 exercises/06_move_semantics/move_semantics6.rs DONE structs1 exercises/07_structs/structs1.rs DONE structs2 exercises/07_structs/structs2.rs PENDING structs3 exercises/07_structs/structs3.rs DONE enums1 exercises/08_enums/enums1.rs PENDING enums2 exercises/08_enums/enums2.rs DONE enums3 exercises/08_enums/enums3.rs PENDING strings1 exercises/09_strings/strings1.rs DONE strings2 exercises/09_strings/strings2.rs DONE strings3 exercises/09_strings/strings3.rs DONE strings4 exercises/09_strings/strings4.rs DONE modules1 exercises/10_modules/modules1.rs DONE modules2 exercises/10_modules/modules2.rs DONE modules3 exercises/10_modules/modules3.rs DONE hashmaps1 exercises/11_hashmaps/hashmaps1.rs DONE hashmaps2 exercises/11_hashmaps/hashmaps2.rs DONE hashmaps3 exercises/11_hashmaps/hashmaps3.rs PENDING quiz2 exercises/quizzes/quiz2.rs DONE options1 exercises/12_options/options1.rs DONE options2 exercises/12_options/options2.rs DONE options3 exercises/12_options/options3.rs PENDING errors1 exercises/13_error_handling/errors1.rs DONE errors2 exercises/13_error_handling/errors2.rs DONE errors3 exercises/13_error_handling/errors3.rs DONE errors4 exercises/13_error_handling/errors4.rs DONE errors5 exercises/13_error_handling/errors5.rs PENDING errors6 exercises/13_error_handling/errors6.rs DONE generics1 exercises/14_generics/generics1.rs DONE generics2 exercises/14_generics/generics2.rs DONE traits1 exercises/15_traits/traits1.rs DONE traits2 exercises/15_traits/traits2.rs DONE traits3 exercises/15_traits/traits3.rs DONE traits4 exercises/15_traits/traits4.rs DONE traits5 exercises/15_traits/traits5.rs DONE quiz3 exercises/quizzes/quiz3.rs DONE lifetimes1 exercises/16_lifetimes/lifetimes1.rs DONE lifetimes2 exercises/16_lifetimes/lifetimes2.rs DONE lifetimes3 exercises/16_lifetimes/lifetimes3.rs DONE tests1 exercises/17_tests/tests1.rs DONE tests2 exercises/17_tests/tests2.rs DONE tests3 exercises/17_tests/tests3.rs DONE tests4 exercises/17_tests/tests4.rs DONE iterators1 exercises/18_iterators/iterators1.rs DONE iterators2 exercises/18_iterators/iterators2.rs DONE iterators3 exercises/18_iterators/iterators3.rs DONE iterators4 exercises/18_iterators/iterators4.rs DONE iterators5 exercises/18_iterators/iterators5.rs DONE box1 exercises/19_smart_pointers/box1.rs DONE rc1 exercises/19_smart_pointers/rc1.rs DONE arc1 exercises/19_smart_pointers/arc1.rs DONE cow1 exercises/19_smart_pointers/cow1.rs DONE threads1 exercises/20_threads/threads1.rs DONE threads2 exercises/20_threads/threads2.rs DONE threads3 exercises/20_threads/threads3.rs DONE macros1 exercises/21_macros/macros1.rs DONE macros2 exercises/21_macros/macros2.rs DONE macros3 exercises/21_macros/macros3.rs DONE macros4 exercises/21_macros/macros4.rs DONE clippy1 exercises/22_clippy/clippy1.rs DONE clippy2 exercises/22_clippy/clippy2.rs DONE clippy3 exercises/22_clippy/clippy3.rs DONE using_as exercises/23_conversions/using_as.rs DONE from_into exercises/23_conversions/from_into.rs DONE from_str exercises/23_conversions/from_str.rs DONE try_from_into exercises/23_conversions/try_from_into.rs DONE as_ref_mut exercises/23_conversions/as_ref_mut.rs ```

This are my local files (after cargo clean and removing the .git directory).

This happened when I pressed next + Enter three times:

https://github.com/rust-lang/rustlings/assets/8530833/f869437a-5812-47be-8450-60c04b7920b9

iamcult commented 5 months ago

Would it be possible to keep around nix as an installation method in v6?

mo8it commented 5 months ago

Would it be possible to keep around nix as an installation method in v6?

No, because I don't use Nix and will not maintain it. You can package it then because v6 will be a standalone binary that you can install with cargo install rustlings.

hamirmahal commented 5 months ago
  • exercises\02_functions\functions1.rs: Add // don't change this line after call_me();. Make it clear to write the function (and not to remove the call).

I was taking a look at exercises/02_functions/functions1.rs just now and I'm glad you said this. It wasn't clear what the reader is expected to do.

hamirmahal commented 5 months ago

It might also be helpful to have an "ideal solution" for each exercise.

mo8it commented 5 months ago

It might also be helpful to have an "ideal solution" for each exercise.

This is one of the main features of v6 :D

Handling solutions is already implemented. I just need to find some time to write the solutions: https://github.com/rust-lang/rustlings/tree/v6/solutions

hamirmahal commented 5 months ago

It might also be helpful to have an "ideal solution" for each exercise.

This is one of the main features of v6 :D

Handling solutions is already implemented. I just need to find some time to write the solutions: https://github.com/rust-lang/rustlings/tree/v6/solutions

Oh, nice! I think I can try contributing to that if it goes in a pull request.

hamirmahal commented 5 months ago

Also, I think it'd be neat if users had an option to automatically open the next exercise in their editor after completing the current one.

mo8it commented 5 months ago

Oh, nice! I think I can try contributing to that if it goes in a pull request.

I plan to write them myself first and then improvements are welcome :D

Also, I think it'd be neat if users had an option to automatically open the next exercise in their editor after completing the current one.

This should also be partially solved since v6 shows you the path of the next exercise as a link in your terminal. Clicking on the link opens the file in your editor. The idea of automatically opening the current file is discarded because it can't work in terminal editor like Helix for example.

mo8it commented 5 months ago

3) Invisible input text

I didn't find a way to really fix it, but now (beta.8) Rustlings expects a single character as input. This means that entering h will not show you that h was entered, but it will react to it and show you the hint. You don't have to press ENTER anymore on Windows.

5) Quiz / 6) Progress bar

Thank you for sharing all the info. This looks good to me! (not a bug, but a source of confusion) Rustlings tells you that some exercises are still pending and goes back to them to let you finish them.

The reason why some exercises like quiz1 were not shown to you in the right order is that you jumped to the next file without entering n for telling Rustlings to go to the next exercise. For example, your list shows that if3 and quiz1 are pending. quiz1 comes directly after if3, but you probably didn't enter n after finishing if3 and instead started editing the file for primitive_types1. Rustlings jumps to the file that was lastly saved.

This was fine before having the interactive list. But now that the list exists and allows you to opt into skipping an exercise, I think we should disable skipping on saving the file of a later exercise. Going back is fine though. I will implement this in the next beta version :)

Thank you again @dotjpg3141 🥰

mo8it commented 5 months ago

But now that the list exists and allows you to opt into skipping an exercise, I think we should disable skipping on saving the file of a later exercise. Going back is fine though.

Done in beta.9 :D

mo8it commented 5 months ago

Love the new direction rustlings is taking! One issue I'm having: After starting rustlings, I get an "invalid argument" for running the intro1 command and rustlings exists.

@vgroenewold I don't have enough information to reproduce this. Could you please tell me what command you tried to run and in which directory? Could you please share the exact error message? Thanks 😊

dotjpg3141 commented 5 months ago

The reason why some exercises like quiz1 were not shown to you in the right order is that you jumped to the next file without entering n for telling Rustlings to go to the next exercise.

That makes a lot of sense. This is probably what happened.

mo8it commented 3 months ago

Version 6 is released now. Thank you all for your feedback 🥰