Skip to content

fix: go backend missing supports_lockfile_url() override#8790

Merged
jdx merged 1 commit intojdx:mainfrom
palootcenas-outreach:fix/go-backend-supports-lockfile-url
Mar 30, 2026
Merged

fix: go backend missing supports_lockfile_url() override#8790
jdx merged 1 commit intojdx:mainfrom
palootcenas-outreach:fix/go-backend-supports-lockfile-url

Conversation

@palootcenas-outreach
Copy link
Copy Markdown
Contributor

Summary

Go backend tools compile from source via go install and don't produce downloadable binary artifacts. The default supports_lockfile_url() returns true, causing --locked mode to fail for any go-backend tool since their lockfile entries can never contain platform-specific download URLs.

This adds supports_lockfile_url() -> false to the Go backend, matching the pattern already used by cargo, npm, pipx, asdf, dotnet, rust, and ubi backends.

The Problem

When using --locked mode with go-backend tools:

# mise.toml
[tools]
"go:golang.org/x/tools/cmd/goimports" = "latest"

mise lock generates entries without download URLs (because there are none — go tools are compiled from source):

# mise.lock
[[tools]]
name = "go:golang.org/x/tools/cmd/goimports"
version = "0.33.0"
backend = "go"
# no checksums/URLs — compiled from source

Then mise install --locked fails because install_version() in src/backend/mod.rs expects lockfile URLs when supports_lockfile_url() returns true.

The Fix

One-line override in src/backend/go.rs:

fn supports_lockfile_url(&self) -> bool {
    false
}

Note: gem, spm, and conda backends may have the same issue — they also don't override supports_lockfile_url() and may compile from source or use non-URL-based installation. Worth checking.

Related

Go backend tools compile from source via `go install` and don't
produce downloadable binary artifacts. The default
supports_lockfile_url() returns true, causing --locked mode to fail
for any go-backend tool since their lockfile entries can never contain
platform-specific download URLs.

Other source-based backends (cargo, npm, pipx, asdf, dotnet, rust,
ubi) already override this to false. This adds the same override for
the go backend.

Fixes the --locked failure for tools like:
  go:golang.org/x/tools/cmd/goimports
  go:github.com/go-delve/delve/cmd/dlv

Discussion: jdx#8789
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the supports_lockfile_url method for the GoBackend in src/backend/go.rs, which currently returns false. I have no feedback to provide.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR adds a one-line supports_lockfile_url() -> false override to GoBackend, fixing a bug where mise install --locked would fail for any go-backend tool because go tools are compiled from source via go install and never produce platform-specific downloadable binary artifacts that can be stored as URLs in a lockfile.\n\n- The fix correctly mirrors the pattern already established by cargo, npm, pipx, asdf, ubi, rust (core plugin), and dotnet (core plugin) backends, all of which return false from supports_lockfile_url().\n- Without this override, install_version() in src/backend/mod.rs (line 996) checks for a lockfile URL and bails with an error, even though go-backend lockfile entries legitimately have no URL.\n- The PR description notes that gem, spm, and conda backends may have the same issue — these are unaddressed in this PR but worth a follow-up.\n- No regression test is added; a new e2e test under e2e/lockfile/ covering --locked mode for a go-backend tool would prevent future regressions.

Confidence Score: 5/5

Safe to merge — the change is minimal, correctly follows established patterns, and directly fixes a broken user-facing workflow.

Single-method override that returns a constant false, consistent with at least seven other backends that have the same pattern. The logic in mod.rs clearly shows this is the correct fix. No risk of regression in unrelated code paths.

No files require special attention — the single changed file is straightforward.

Important Files Changed

Filename Overview
src/backend/go.rs Adds supports_lockfile_url() -> false override to GoBackend, fixing --locked mode failures for go-backend tools that compile from source and have no downloadable binary URLs.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["mise install --locked (go:some/tool)"] --> B["install_version() — mod.rs:996"]
    B --> C{"ctx.locked &&\nnot tool_stub?"}
    C -- No --> F["Proceed with install via go install"]
    C -- Yes --> D{"supports_lockfile_url()?"}
    D -- "true (before fix)\ndefault" --> E["❌ bail! — No lockfile URL found\n(go tools have no binary URLs)"]
    D -- "false (after fix)\nGoBackend override" --> F
    F --> G["go install golang.org/x/...@version"]
    G --> H["✅ Tool installed from source"]
Loading

Reviews (1): Last reviewed commit: "fix: go backend missing supports_lockfil..." | Re-trigger Greptile

Comment on lines +37 to +39
fn supports_lockfile_url(&self) -> bool {
false
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No regression test for locked mode

The fix is correct, but there's no new e2e test covering mise install --locked with a go-backend tool. The existing lockfile tests (e.g. e2e/lockfile/test_lockfile_install, e2e/lockfile/test_lockfile_locked_mode) don't exercise this code path for the go backend. Without a test, a future refactor that accidentally reverts this override or changes how supports_lockfile_url() is wired would silently re-introduce the regression.

Consider adding a small test under e2e/lockfile/ — something like:

#!/usr/bin/env bash
export MISE_LOCKFILE=1

cat <<EOF >mise.toml
[tools]
"go:golang.org/x/tools/cmd/goimports" = "latest"
EOF

# mise lock should succeed and produce an entry without a URL
mise lock
assert_contains "mise.lock" 'backend = "go"'

# mise install --locked should succeed (not bail with "No lockfile URL found")
mise install --locked

@jdx jdx merged commit 0fafcaf into jdx:main Mar 30, 2026
35 checks passed
mise-en-dev added a commit that referenced this pull request Mar 31, 2026
### 🚀 Features

- **(python)** add GitHub provenance verification for prebuilt binaries
by @malept in [#8820](#8820)

### 🐛 Bug Fixes

- **(ci)** use rustls-native-roots for Windows CI build by @jdx in
[#8822](#8822)
- **(go)** improve version fetching logic to support deeply nested
sub-modules by @roele in [#8823](#8823)
- **(shim)** prevent infinite recursion when system shims dir is on PATH
by @andrewthauer in [#8816](#8816)
- go backend missing supports_lockfile_url() override by
@palootcenas-outreach in [#8790](#8790)
- strip shims from PATH in credential and template subprocesses by
@antonioacg in [#8802](#8802)

### 📚 Documentation

- fix typo in shims documentation for fish by @roele in
[#8798](#8798)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:alpine docker digest to 3e6d001 by
@renovate[bot] in [#8794](#8794)
- pin dependencies by @renovate[bot] in
[#8793](#8793)

### 📦 Registry

- fix flutter version sorting by @roele in
[#8818](#8818)
- add svgo (npm:svgo) by @3w36zj6 in
[#8817](#8817)

### New Contributors

- @antonioacg made their first contribution in
[#8802](#8802)
- @palootcenas-outreach made their first contribution in
[#8790](#8790)

## 📦 Aqua Registry Updates

#### New Packages (3)

- [`RasKrebs/sonar`](https://github.com/RasKrebs/sonar)
- [`emacs-eask/cli`](https://github.com/emacs-eask/cli)
-
[`superradcompany/microsandbox`](https://github.com/superradcompany/microsandbox)

#### Updated Packages (4)

- [`dimo414/bkt`](https://github.com/dimo414/bkt)
- [`lxc/incus`](https://github.com/lxc/incus)
-
[`shinagawa-web/gomarklint`](https://github.com/shinagawa-web/gomarklint)
- [`updatecli/updatecli`](https://github.com/updatecli/updatecli)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants