Skip to content

bugs in checkhealth(possibly more) #2065

@Universal-Invariant

Description

@Universal-Invariant

I've searched open issues for similar requests

  • Yes

I've recently downloaded the latest plugin version of mason.nvim

  • Yes

Problem description

Checkhealth cannot parse versions(specifically of go)

Expected behavior

Should work.

        check_thunk {
            cmd = "go",
            args = { "version" },
            name = "Go",
            relaxed = true,
            version_check = function(version)
                -- Parses output such as "go version go1.17.3 darwin/arm64" into major, minor, patch components
                local _, _, major, minor = version:find "go(%d+)%.(%d+)"
                -- Due to https://go.dev/doc/go-get-install-deprecation
                if (not major or not minor) or (not (tonumber(major) >= 1 and tonumber(minor) >= 17)) then
                    return "Go version must be >= 1.17. ["..version.."]"
                end
            end,
        },

I added the more robust check not major or not minor. What is happening is this: I use go.bat in some of my projects(unrelated to go and just usually the same as run. I probably should start using run instead of go)

the check is running cmd = go which is running the go.bat and it's checking what the batch file prints out.

Rather than just running an arbitrary go likely one should do a more robust check like find the executable in the path or check GOROOT.

It should, of course, work for windows and linux. If I change go to go.exe in the cmd then it works.

But this is a general problem with all the checks and possibly a general problem with programs used by mason. It's very fragile and could cause spurious behavior.

Steps to reproduce

checkhealth mason

Neovim version (>= 0.10.0)

Latest

Operating system/version

Windows 11

Healthcheck output

ADVICE cannot compare nil with number

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions