gohugoio/hugo · error

failed to get

Error message

failed to get %q: %w

What it means

Returned by Client.get (the lower-level runner behind Client.Get / `hugo mod get`) when c.runGo(... "get" ...) fails. The args slice is quoted in the message; the underlying error is wrapped with %w. runGo can swallow exec.ErrNotFound (recording goBinaryStatusNotFound) and some 'too old Go' errors, so a surfaced error here typically means Go ran but the get command itself failed.

Solutions

  1. Read the wrapped error and the stderr hint Hugo prints (it flags 'invalid version: unknown revision' with remediation guidance).
  2. For unknown revisions, edit go.mod to a valid branch/tag (e.g. master) then `hugo mod graph` to re-resolve.
  3. Set GOPRIVATE/GONOPROXY/GOPROXY appropriately in your environment or [module] config for private/restricted registries.
  4. Run `go get <module>@<version>` directly to reproduce and get Go's native diagnostics, then fix go.mod/go.sum.
  5. Run `hugo mod tidy` to reconcile requirements and sums.

Example fix

# before
hugo mod get github.com/foo/bar@v0.9.0   # tag force-pushed away -> unknown revision

# after
# edit go.mod require line to a valid ref
hugo mod get github.com/foo/bar@master
hugo mod tidy
Defensive patterns

Strategy: retry

Validate before calling

// Validate module path + reachability before `hugo mod get`.
func modulePathValid(path string) error {
    return module.CheckPath(path) // nil == valid Go module path
}

func proxyReachable() error {
    // e.g. HEAD check against GOPROXY in your environment
    return nil
}

Type guard

func isProbablyModule(path string) bool {
    return module.CheckPath(path) == nil
}

Try / catch

if err := client.Get(args...); err != nil {
    if strings.Contains(err.Error(), "unknown revision") {
        // edit go.mod to a valid branch and retry
    } else if isTransient(err) {
        // network blip: retry with backoff
    }
}

Prevention

When it happens

Trigger: Running `hugo mod get <module>` or `hugo mod get -u` where `go get` exits non-zero: module not found on the proxy, network failure, unknown revision, go.sum mismatch, or an invalid module path/version argument.

Common situations: Module path typo or missing vCS ref (force-pushed tag); GOPROXY blocked/unreachable in corporate networks; private module without GOPRIVATE set; version string malformed; go.sum out of date after a manual go.mod edit.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/e507b7bf259eda65. Report an issue: GitHub.

Appendix: source

Thrown at modules/client.go:358

			} else if update && patch {
				args = append(args, "-u=patch")
			}
			args = append(args, m)

			if err := c.get(args...); err != nil {
				return err
			}
		}

		return nil
	}

	return c.get(args...)
}

func (c *Client) get(args ...string) error {
	if err := c.runGo(context.Background(), c.logger.StdOut(), append([]string{"get"}, args...)...); err != nil {
		return fmt.Errorf("failed to get %q: %w", args, err)
	}
	return nil
}

// Init initializes this as a Go Module with the given path.
// If path is empty, Go will try to guess.
// If this succeeds, this project will be marked as Go Module.
func (c *Client) Init(path string) error {
	err := c.runGo(context.Background(), c.logger.StdOut(), "mod", "init", path)
	if err != nil {
		return fmt.Errorf("failed to init modules: %w", err)
	}

	c.GoModulesFilename = filepath.Join(c.ccfg.WorkingDir, goModFilename)

	return nil
}

View on GitHub (pinned to 52c9bd7908)