-
Notifications
You must be signed in to change notification settings - Fork 2
fix: Docker not found error, better UX #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves the user experience when Docker CLI is not installed by adding a friendly error message instead of the default "No such file or directory" error. The change is localized to the init command's cleanup function.
Changes:
- Adds
docker_not_found_error()helper function that returns a user-friendly error message - Wraps two Docker command invocations (
docker imagesanddocker rmi) with error handling that detectsErrorKind::NotFoundand returns the friendly message
src/commands/init/mod.rs
Outdated
| "Docker CLI not found. Install Docker Desktop and ensure the 'docker' command is on PATH, then re-run 'foc-devnet init'." | ||
| .to_string() | ||
| .into() |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message string should be defined as a constant rather than being hardcoded. According to the project's coding guidelines, magic strings should be extracted to constants, typically in src/constants.rs. This improves maintainability and allows the message to be reused if needed elsewhere in the codebase.
Consider defining a constant like:
pub const DOCKER_NOT_FOUND_ERROR: &str = "Docker CLI not found. Install Docker Desktop and ensure the 'docker' command is on PATH, then re-run 'foc-devnet init'.";| .output() | ||
| .map_err(|err| match err.kind() { | ||
| ErrorKind::NotFound => docker_not_found_error(), | ||
| _ => err.into(), | ||
| })?; |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error handling for Docker CLI not found is only applied in the init command's cleanup function, but there are 20+ other locations throughout the codebase that use Command::new("docker") without this error handling. This creates an inconsistent user experience where users might get a helpful error message here but a generic "No such file or directory" error elsewhere.
Consider centralizing this error handling in the docker_command function in src/docker/core.rs (line 51-53), which already serves as the centralized wrapper for Docker commands. This would provide consistent error messages across the entire codebase without requiring changes to every call site.
For example, the run_command function in src/docker/core.rs could be enhanced to detect ErrorKind::NotFound and provide context about which program was not found.
src/commands/init/mod.rs
Outdated
|
|
||
| /// Create a friendly error for missing Docker CLI. | ||
| fn docker_not_found_error() -> Box<dyn std::error::Error> { | ||
| "Docker CLI not found. Install Docker Desktop and ensure the 'docker' command is on PATH, then re-run 'foc-devnet init'." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just "Install Docker" since we don't actually need Desktop?
rvagg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about std::io::ErrorKind::NotFound
No description provided.