abiosoft/colima · error

error modifying %s: %w

Error message

error modifying %s: %w

What it means

Returned by generateSSHConfig (app/app.go:736) when os.WriteFile fails while prepending 'Include <colima ssh_config>' to ~/.ssh/config (the %s is that path). The write happens only when the Include line is absent, and failure means the SSH config could not be updated.

Source

Thrown at app/app.go:736

		// not an include line
		if len(words) < 2 {
			continue
		}

		if words[0] == "Include" {
			sshConfig := words[1]
			sshConfig = strings.Replace(sshConfig, "~/", "$HOME/", 1)
			sshConfig = os.ExpandEnv(sshConfig)
			if sshConfig == sshFileColima {
				// already present
				return nil
			}
		}
	}

	// not found, prepend file
	if err := os.WriteFile(sshFileSystem, []byte(includeLine+"\n\n"+string(sshContent)), 0644); err != nil {
		return fmt.Errorf("error modifying %s: %w", sshFileSystem, err)
	}
	return nil
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Restore ownership and write permission: `sudo chown $(id -un):$(id -gn) ~/.ssh/config && chmod u+w ~/.ssh/config`
  2. If ~/.ssh/config is a symlink, ensure its target is writable
  3. Check disk space with `df -h ~` and free space if full
  4. Fallback: `colima start --modify-ssh-config=false`, then manually prepend 'Include ~/.colima/ssh_config' to ~/.ssh/config

Example fix

# before
colima start   # error modifying /Users/me/.ssh/config: ... permission denied

# after
sudo chown $(id -un):$(id -gn) ~/.ssh/config
chmod u+w ~/.ssh/config
colima start
Defensive patterns

Strategy: validation

Validate before calling

// Probe writability of ~/.ssh/config before colima start
sshCfg := filepath.Join(home, ".ssh", "config")
if f, err := os.OpenFile(sshCfg, os.O_WRONLY|os.O_APPEND, 0); err != nil {
    return fmt.Errorf("~/.ssh/config not writable; fix ownership/mode or use --modify-ssh-config=false")
} else {
    _ = f.Close()
}

Try / catch

if err := runColimaStart(); err != nil {
    if strings.Contains(err.Error(), "error modifying") && strings.Contains(err.Error(), ".ssh/config") {
        // write denied: chmod u+w / chown the file, or fall back to manual Include management
    }
    return err
}

Prevention

When it happens

Trigger: ~/.ssh or ~/.ssh/config is not writable by the current user (root-owned file, mode without u+w), the file is a symlink into a read-only location, or the disk is full. The earlier branch (creating the file when missing) uses the same message at line 693.

Common situations: Root-owned ~/.ssh/config after sudo usage or backup restore; ~/.ssh synced onto a read-only mount; full disk; the file mode deliberately set to 0444.

Related errors


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