How to Use Manual Run Mode in Rustlings Watch Mode
To use manual run mode in Rustlings watch mode, start the tool with the --manual-run flag and press r to execute the current exercise on demand instead of relying on automatic file detection.
The Rustlings project is the official interactive exercise collection for learning Rust, maintained by the Rust Language organization. When working through exercises in watch mode, the tool typically monitors your source files for changes and automatically re-runs the current exercise. However, in containerized environments or on certain filesystems, this automatic detection fails, making manual run mode in Rustlings watch mode essential for a smooth learning experience.
What Is Manual Run Mode in Rustlings?
Manual run mode is a fallback mechanism designed for environments where file system watchers cannot operate reliably. By default, rustlings watch uses notify::RecommendedWatcher to detect when you save changes to an exercise file. When this watcher fails—common in Docker containers, WSL, or network-mounted filesystems—you can disable it entirely and trigger execution manually.
The implementation spans several core modules in the rust-lang/rustlings repository:
src/main.rs– Parses the--manual-runCLI flagsrc/watch.rs– Contains therun_watchfunction that conditionally creates the watchersrc/watch/terminal_event.rs– Handles therkey mapping toInputEvent::Runsrc/watch/state.rs– Renders ther:runhint in the UI prompt
Starting Rustlings with the Manual Run Flag
To activate manual run mode, append the --manual-run flag when launching the watch command:
rustlings watch --manual-run
When you execute this command, the following internal process occurs:
src/main.rs(lines 34-38) parsesArgs::manual_runand setsnotify_exercise_namestoNone, signaling that no file watcher should be created.src/watch.rs(lines 68-92) receives this signal in therun_watchfunction, settingmanual_run = trueand skipping the initialization ofnotify::RecommendedWatcher.- The UI initializes without automatic file monitoring, displaying the prompt with the
r:runoption visible.
How to Trigger Exercises Manually
Once in manual run mode, the workflow changes from automatic to on-demand execution:
- Edit your exercise file (e.g.,
exercises/01_variables/variables1.rs) in your editor. - Save the file—no automatic execution occurs.
- Return to the Rustlings terminal window and press
r.
The key press is processed through the following chain:
src/watch/terminal_event.rs(lines 38-40) captures therkey interminal_event_handlerand maps it toInputEvent::Run.- The event propagates to the main watch loop in
src/watch.rs, which callsWatchState::run_current_exercise. src/watch/state.rs(lines 92-95) ensures ther:runhint appears in the prompt only whenmanual_runis active.
When to Use Manual Run Mode
You should use the --manual-run flag in the following scenarios:
- Containerized Development: When running Rustlings inside Docker or Podman, the
notifycrate often cannot access the host's filesystem events. - Windows Subsystem for Linux (WSL): WSL1 and some WSL2 configurations have limited inotify support, causing the automatic watcher to fail silently or with the
NOTIFY_ERRmessage. - Network Filesystems: NFS, SMB, or other remote mounts may not propagate file change events to the local watcher.
- Resource Constraints: On systems with strict file descriptor limits, disabling the watcher reduces resource consumption.
If the automatic detection fails, Rustlings displays the NOTIFY_ERR constant (defined in src/watch.rs, lines 84-90), which explicitly recommends running rustlings --manual-run to deactivate the file watcher.
Summary
- Manual run mode disables the automatic file watcher in Rustlings, allowing you to trigger exercise execution on demand.
- Launch with
rustlings watch --manual-runto skipnotify::RecommendedWatcherinitialization and avoid filesystem detection issues. - Press
rin the watch UI to manually execute the current exercise, handled byterminal_event_handlerinsrc/watch/terminal_event.rs. - Use this mode in Docker containers, WSL environments, or when the automatic watcher fails with the
NOTIFY_ERRmessage.
Frequently Asked Questions
What is the difference between rustlings watch and rustlings watch --manual-run?
Standard rustlings watch uses a file system watcher to automatically detect when you save changes to an exercise file and immediately re-runs the exercise. When you add --manual-run, the tool skips creating the notify::RecommendedWatcher entirely, requiring you to press r to trigger execution manually. The UI prompt shows r:run only when manual mode is active.
Why does the file watcher fail in Docker or WSL?
The file watcher relies on OS-specific notification systems like inotify on Linux. Docker containers often run with restricted capabilities or on overlay filesystems that don't propagate these events to the host. WSL1 lacks full inotify support, and while WSL2 improved this, cross-filesystem access (Windows files accessed from WSL) still breaks file watching. In these cases, Rustlings displays the NOTIFY_ERR message defined in src/watch.rs.
Can I switch from manual mode to automatic mode without restarting?
No, you cannot toggle between modes while the watch process is running. The manual_run boolean is set during initialization in src/watch.rs based on the CLI flag, and the watcher thread is either created or omitted at startup. To change modes, you must quit the current session with q and restart Rustlings with or without the --manual-run flag.
What other keyboard shortcuts are available in Rustlings watch mode?
Besides r for manual run (when enabled), the watch mode supports several shortcuts handled in src/watch/terminal_event.rs: h displays a hint for the current exercise, l lists all exercises, c checks all exercises across the entire course, x resets the current exercise to its original state, and q quits the program. The available options are displayed in the bottom prompt managed by src/watch/state.rs.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →