Skip to content

False 'go/gofmt not installed' warnings on Windows (and gofmt false negative on all platforms) #57

@Zireael

Description

@Zireael

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

  1. On Windows 11, install Go SDK (any version) via the official Windows installer at C:\Go\bin
  2. Launch an editor via GUI (Start Menu, taskbar, etc.) that may not inherit the full user PATH
  3. Open a project containing go.mod
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions