lima-vm/lima · error

path %#q is not an absolute path

Error message

path %#q is not an absolute path

What it means

validatePath enforces that every path used in networks.yaml (binaries, sockets) is an absolute path starting with '/', because these values are embedded into sudoers rules and daemon arguments. A relative path fails immediately with this error.

Source

Thrown at pkg/networks/validate.go:102

	return nil
}

// findBaseDirectory removes non-existing directories from the end of the path.
func findBaseDirectory(path string) string {
	if _, err := os.Lstat(path); errors.Is(err, os.ErrNotExist) {
		if path != "/" {
			return findBaseDirectory(filepath.Dir(path))
		}
	}
	return path
}

func validatePath(path string, allowDaemonGroupWritable bool) error {
	if path == "" {
		return nil
	}
	if path[0] != '/' {
		return fmt.Errorf("path %#q is not an absolute path", path)
	}
	if strings.ContainsRune(path, ' ') {
		return fmt.Errorf("path %#q contains whitespace", path)
	}
	fi, err := os.Lstat(path)
	if err != nil {
		return err
	}
	file := "file"
	if fi.Mode().IsDir() {
		file = "dir"
	}
	// TODO: should we allow symlinks when both the link and the target are secure?
	// E.g. on macOS /var is a symlink to /private/var, /etc to /private/etc
	if (fi.Mode() & fs.ModeSymlink) != 0 {
		return fmt.Errorf("%s %#q is a symlink", file, path)
	}
	stat, ok := osutil.SysStat(fi)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Replace the value with a fully absolute path starting with '/' (expand ~ manually, e.g. /Users/alice/opt/socket_vmnet/bin/socket_vmnet).
  2. Also avoid whitespace in the path (next check after this one).
  3. Re-run validation after fixing.
  4. If the binary lives under your home dir, symlink or install it into a standard absolute location like /usr/local/bin or the Homebrew prefix.

Example fix

# before (networks.yaml)
paths:
  vdeSwitch: ~/opt/vde/bin/vde_switch
# after
paths:
  vdeSwitch: /Users/alice/opt/vde/bin/vde_switch
Defensive patterns

Strategy: validation

Validate before calling

function validateAbsolutePath(p, field) {
  if (!p) return null;
  if (!p.startsWith('/')) return `${field}: '${p}' is not an absolute path`;
  return null;
}
Object.entries(config.paths || {}).forEach(([k, v]) => validateAbsolutePath(v, `paths.${k}`));

Type guard

function isAbsolutePath(p) {
  return typeof p === 'string' && p.startsWith('/');
}

Prevention

When it happens

Trigger: A `paths.*` entry or socket path in networks.yaml is given as a relative value (e.g. 'bin/socket_vmnet' or '~/opt/socket_vmnet'); validatePath is invoked from Validate for each configured path.

Common situations: Using '~' in the path (not expanded to an absolute path); editing networks.yaml with a relative path assuming CWD resolution; templating the config with variables that resolved empty.

Related errors


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