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
- Convert the path with filepath.Abs before calling, anchored to your working directory
- Expand "~" to the home directory yourself (os.UserHomeDir) before passing
- 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
- Always normalize with filepath.Abs before tool calls
- Expand "~" with os.UserHomeDir — IsAbs("~/x") is false
- Use filepath.IsAbs as a pre-check in wrappers around the tools
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
- path is empty
- local files are not cached
- invalid digest algorithm %#q
- invalid pseudo tag for virtiofs: %#q
- field `provision[%d].path` must be an absolute path
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/b4f3814bde06884c.
Report an issue: GitHub.