lima-vm/lima · error

expected an absolute path, got a relative path: %#q

Error message

expected an absolute path, got a relative path: %#q

What it means

TranslateHostPath requires an absolute host path because it must map unambiguously onto a host location shared with the VM. Relative paths are rejected with this error since there is no defined working directory to resolve them against. The offending value is quoted with %#q for easy diagnosis.

Source

Thrown at pkg/mcp/toolset/toolset.go:110

}

func (ts *ToolSet) Close() error {
	var err error
	if ts.sftp != nil {
		err = errors.Join(err, ts.sftp.Close())
	}
	if ts.sftpCmd != nil && ts.sftpCmd.Process != nil {
		err = errors.Join(err, ts.sftpCmd.Process.Kill())
	}
	return err
}

func (ts *ToolSet) TranslateHostPath(hostPath string) (string, error) {
	if hostPath == "" {
		return "", errors.New("path is empty")
	}
	if !filepath.IsAbs(hostPath) {
		return "", fmt.Errorf("expected an absolute path, got a relative path: %#q", hostPath)
	}
	// TODO: make sure that hostPath is mounted
	return hostPath, nil
}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Convert the path with filepath.Abs before calling, anchored to your working directory
  2. Expand "~" to the home directory yourself (os.UserHomeDir) before passing
  3. Store absolute paths in configuration consumed by the MCP tools

Example fix

// before
TranslateHostPath("./data")
// after
abs, _ := filepath.Abs("./data")
TranslateHostPath(abs)
Defensive patterns

Strategy: validation

Validate before calling

if !filepath.IsAbs(hostPath) {
    abs, err := filepath.Abs(hostPath)
    if err != nil { return err }
    hostPath = abs
}

Try / catch

path, err := ts.TranslateHostPath(p)
if err != nil && strings.Contains(err.Error(), "relative path") {
    abs, aerr := filepath.Abs(p)
    if aerr != nil { return aerr }
    path, err = ts.TranslateHostPath(abs)
}

Prevention

When it happens

Trigger: Calling ListDirectory, ReadFile, WriteFile, Glob, SearchFileContent, or RunShellCommand with a path like "foo.txt", "./dir", or "~/docs" — any value for which filepath.IsAbs is false.

Common situations: Passing a relative path from a project-local config; using "~" which is not expanded by the library; an agent generating shorthand paths; code that previously ran with a different cwd now producing relative paths.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/b4f3814bde06884c. Report an issue: GitHub.