Description
AFT emits spurious "not installed" warnings for go and gofmt on Windows 11 even when both tools are correctly installed on the system PATH. The gofmt warning also fires on macOS and Linux.
Affected Environments
- gofmt: all platforms (macOS, Linux, Windows) — guaranteed false negative
- go: Windows only (when Go SDK's
bin directory is absent from the process's inherited PATH — common for editors launched from GUI shortcuts)
- All tools resolved via
try_well_known_path_lookup: Windows only (the fallback was entirely disabled)
Root Causes
1. gofmt --version exits non-zero (all platforms)
try_path_lookup (crates/aft/src/format.rs:328-356) uses Command::new(tool).arg("--version") as the sole PATH probe and returns None when the child exits with a non-zero status. gofmt does not accept --version — it prints "gofmt (no version information)" to stdout but exits with code 1. Therefore try_path_lookup("gofmt") always returns None regardless of whether gofmt is installed and on PATH.
2. try_well_known_path_lookup unconditionally disabled on Windows
try_well_known_path_lookup (format.rs:373-390) hardcodes cfg!(windows) { return None; } because its hardcoded search list (/opt/homebrew/bin, /usr/local/bin, ~/.cargo/bin, ~/go/bin, ~/.local/bin) is exclusively POSIX. Windows has no fallback to its common Go install locations such as C:\Go\bin or %LOCALAPPDATA%\Programs\Go\bin.
3. install_hint("go") provides macOS-only guidance
The install hint shown to users mentions only macOS Homebrew paths (/opt/homebrew/bin, /usr/local/bin). Windows users receive no actionable install-path guidance.
4. Duplicate tool-detection logic
detect_missing_tools (format.rs) and detect_missing_tools_for_languages (commands/configure.rs) each maintain their own near-identical copy of the formatter/checker candidate tables and tool-resolution logic. The configure.rs path lacked the well-known-location fallback entirely, meaning it had no secondary search beyond PATH.
Steps to Reproduce
- On Windows 11, install Go SDK (any version) via the official Windows installer at
C:\Go\bin
- Launch an editor via GUI (Start Menu, taskbar, etc.) that may not inherit the full user PATH
- Open a project containing
go.mod
- Observe "go not found" and/or "gofmt not found" install-hint warnings on the first tool call
Expected Behavior
gofmt correctly detected as present when on PATH (despite its --version exit code)
go resolved through well-known Windows install paths (C:\Go\bin, C:\Program Files\Go\bin, %USERPROFILE%\go\bin) when PATH is incomplete
- Platform-appropriate install hint text for Windows users
- Unified tool-resolution logic shared between format-time and configure-time detection
Related Work
Fix PR: (will be submitted with link to this issue)
Fix commit (Zireael/aft fork): a0c93e8
Description
AFT emits spurious "not installed" warnings for
goandgofmton Windows 11 even when both tools are correctly installed on the system PATH. Thegofmtwarning also fires on macOS and Linux.Affected Environments
bindirectory is absent from the process's inherited PATH — common for editors launched from GUI shortcuts)try_well_known_path_lookup: Windows only (the fallback was entirely disabled)Root Causes
1.
gofmt --versionexits non-zero (all platforms)try_path_lookup(crates/aft/src/format.rs:328-356) usesCommand::new(tool).arg("--version")as the sole PATH probe and returnsNonewhen the child exits with a non-zero status.gofmtdoes not accept--version— it prints "gofmt (no version information)" to stdout but exits with code 1. Thereforetry_path_lookup("gofmt")always returnsNoneregardless of whethergofmtis installed and on PATH.2.
try_well_known_path_lookupunconditionally disabled on Windowstry_well_known_path_lookup(format.rs:373-390) hardcodescfg!(windows) { return None; }because its hardcoded search list (/opt/homebrew/bin,/usr/local/bin,~/.cargo/bin,~/go/bin,~/.local/bin) is exclusively POSIX. Windows has no fallback to its common Go install locations such asC:\Go\binor%LOCALAPPDATA%\Programs\Go\bin.3.
install_hint("go")provides macOS-only guidanceThe install hint shown to users mentions only macOS Homebrew paths (
/opt/homebrew/bin,/usr/local/bin). Windows users receive no actionable install-path guidance.4. Duplicate tool-detection logic
detect_missing_tools(format.rs) anddetect_missing_tools_for_languages(commands/configure.rs) each maintain their own near-identical copy of the formatter/checker candidate tables and tool-resolution logic. Theconfigure.rspath lacked the well-known-location fallback entirely, meaning it had no secondary search beyond PATH.Steps to Reproduce
C:\Go\bingo.modExpected Behavior
gofmtcorrectly detected as present when on PATH (despite its--versionexit code)goresolved through well-known Windows install paths (C:\Go\bin,C:\Program Files\Go\bin,%USERPROFILE%\go\bin) when PATH is incompleteRelated Work
Fix PR: (will be submitted with link to this issue)
Fix commit (Zireael/aft fork): a0c93e8