lima-vm/lima · error

path %#q contains whitespace

Error message

path %#q contains whitespace

What it means

validatePath rejects any configured path containing a space character, because these paths are interpolated into sudoers files and shell-ish daemon invocations where spaces break parsing. The error quotes the offending path.

Source

Thrown at pkg/networks/validate.go:105

// 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)
	if !ok {
		// should never happen
		return fmt.Errorf("could not retrieve stat buffer for %#q", path)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Move/reinstall the binary to a space-free absolute path (e.g. /usr/local/bin or /opt/homebrew/opt/...) and update networks.yaml.
  2. If the directory name can't change, create a symlink from a space-free path and configure that path in networks.yaml.
  3. Double-check the YAML value for accidental internal spaces or tabs.
  4. Re-run validation after the change.

Example fix

# before (networks.yaml)
paths:
  socketVMNet: "/Applications/My Tools/bin/socket_vmnet"
# after
paths:
  socketVMNet: /usr/local/bin/socket_vmnet
Defensive patterns

Strategy: validation

Validate before calling

function validateNoSpaces(p, field) {
  if (!p) return null;
  if (p.includes(' ')) return `${field}: '${p}' contains whitespace`;
  return null;
}
Object.entries(config.paths || {}).forEach(([k, v]) => validateNoSpaces(v, `paths.${k}`));

Type guard

function isSpaceFreePath(p) {
  return typeof p === 'string' && !p.includes(' ');
}

Prevention

When it happens

Trigger: A `paths.*` value (or socket path) in networks.yaml contains a space — e.g. an install directory like '/Applications/My Tools/bin/socket_vmnet' — and networks.Validate runs validatePath on it.

Common situations: Installing vde/socket_vmnet under a directory with spaces ('Application Support', user names with spaces); copying a path from Finder with a volume name containing spaces.

Related errors


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