abiosoft/colima · error

error preparing daemon directory: %w

Error message

error preparing daemon directory: %w

What it means

Manager.Start (the entry the CLI uses when a rootful daemon is needed) first best-effort-stops a previous daemon, then calls init(). This is the outer wrapper around that init failure — the underlying cause is the MkdirAll of <profile ConfigDir>/daemon failing exactly as in the 'error preparing vmnet' case; you see this message when it surfaces from daemon Start.

Source

Thrown at daemon/daemon.go:97

	ctx = context.WithValue(ctx, process.CtxKeyDaemon(), s.Running)

	for _, p := range processesFromConfig(conf) {
		pErr := p.Alive(ctx)
		s.Processes = append(s.Processes, processStatus{
			Name:    p.Name(),
			Running: pErr == nil,
			Error:   pErr,
		})
	}
	return
}

func (l processManager) Start(ctx context.Context, conf config.Config) error {
	_ = l.Stop(ctx, conf) // this is safe, nothing is done when not running

	if err := l.init(); err != nil {
		return fmt.Errorf("error preparing daemon directory: %w", err)
	}

	args := []string{osutil.Executable(), "daemon", "start", config.CurrentProfile().ShortName}

	if conf.Network.Address {
		args = append(args, "--vmnet")
		args = append(args, "--vmnet-mode", conf.Network.Mode)
		args = append(args, "--vmnet-interface", conf.Network.BridgeInterface)
	}
	if conf.MountINotify {
		args = append(args, "--inotify")
		args = append(args, "--inotify-runtime", conf.Runtime)
		for _, mount := range conf.MountsOrDefault() {
			p, err := util.CleanPath(mount.Location)
			if err != nil {
				return fmt.Errorf("error sanitising mount path for inotify: %w", err)
			}
			args = append(args, "--inotify-dir", p)

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. run `colima start --very-verbose` and read the wrapped cause below 'error preparing daemon directory'
  2. fix ownership of the profile config dir: sudo chown -R $(whoami) ~/.colima
  3. ensure COLIMA_HOME is set to a writable directory and exported to the colima process
  4. free disk space or repair permissions on the parent directory
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight the exact directory Start will create
dir := filepath.Join(config.CurrentProfile().ConfigDir(), "daemon")
if fi, err := os.Stat(filepath.Dir(dir)); err == nil && !fi.IsDir() {
    return fmt.Errorf("%s exists but is not a directory — remove it first", filepath.Dir(dir))
}
if err := fsutil.MkdirAll(dir, 0755); err != nil {
    return err // surface errno before invoking daemon Start
}

Try / catch

if err := daemon.Start(ctx, conf); err != nil {
    if strings.HasPrefix(err.Error(), "error preparing daemon directory") {
        cause := errors.Unwrap(err) // *fs.PathError from MkdirAll
        // act on cause: chown for EACCES, cleanup for ENOSPC/EROFS
    }
}

Prevention

When it happens

Trigger: `colima start` with --network-address (vmnet) or --mount-inotify enabled triggers daemon Start; the MkdirAll of ~/.colima/<profile>/daemon fails due to root-owned path segments, unwritable COLIMA_HOME, or full disk.

Common situations: first start after ever running colima with sudo; profile directories created by root; CI runners with read-only home or tiny disk quotas.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/aa28f215c9b8fc32. Report an issue: GitHub.