abiosoft/colima · error
error retrieving current working directory: %w
Error message
error retrieving current working directory: %w
What it means
Inside SSH, colima resolves the current working directory with os.Getwd to check whether it is mounted in the guest (preventing cd errors with limactl ssh). This error means the process's cwd became invalid, typically a directory deleted or made unreadable while the shell was still in it.
Source
Thrown at app/app.go:313
}
log.Println("done")
if err := generateSSHConfig(false); err != nil {
log.Trace("error generating ssh_config: %w", err)
}
return nil
}
func (c colimaApp) SSH(args ...string) error {
ctx := context.Background()
if !c.guest.Running(ctx) {
return fmt.Errorf("%s not running", config.CurrentProfile().DisplayName)
}
workDir, err := os.Getwd()
if err != nil {
return fmt.Errorf("error retrieving current working directory: %w", err)
}
// peek the current directory to see if it is mounted to prevent `cd` errors
// with limactl ssh
if err := func() error {
conf, err := configmanager.LoadInstance()
if err != nil {
return err
}
pwd, err := util.CleanPath(workDir)
if err != nil {
return err
}
for _, m := range conf.MountsOrDefault() {
location := m.MountPoint
if location == "" {
location = m.Location
}
location, err := util.CleanPath(location)View on GitHub (pinned to c3a5f9184d)
Solutions
- Change into an existing directory first: `cd ~ && colima ssh`
- In scripts, invoke colima ssh from a stable directory (e.g. $HOME) instead of a temp workspace
- Remount or restore access to the directory if it must be used
- Avoid deleting the cwd of a long-lived shell session
Example fix
# before (cwd was deleted by a cleanup step) cd /tmp/build-42 && colima ssh # after cd "$HOME" && colima ssh
Defensive patterns
Strategy: validation
Validate before calling
// ensure the cwd is still valid before ssh
if wd, err := os.Getwd(); err != nil {
if cerr := os.Chdir(os.Getenv("HOME")); cerr != nil {
return cerr
}
} else if _, serr := os.Stat(wd); serr != nil {
if cerr := os.Chdir(os.Getenv("HOME")); cerr != nil {
return cerr
}
} Type guard
func isCwdError(err error) bool {
return err != nil && strings.Contains(err.Error(), "error retrieving current working directory")
} Try / catch
if err := a.SSH(args...); err != nil {
if isCwdError(err) {
// the cwd vanished: chdir to $HOME and retry
if cerr := os.Chdir(os.Getenv("HOME")); cerr == nil {
return a.SSH(args...)
}
}
return err
} Prevention
- Launch colima ssh from stable directories like $HOME
- Do not delete the working directory of running shells
- In scripts, cd to a known-good dir before invoking colima
When it happens
Trigger: Invoking colima ssh from a directory that was removed (a cleaned tmp/project dir), an unmounted network volume, or a cwd with revoked permissions.
Common situations: A script runs in a scratch dir that another step deletes before calling colima ssh; cwd on an ejected/unmounted drive; permissions changed by another user.
Related errors
- %s not running
- error reading ssh config: %w
- error modifying %s: %w
- cannot read file '%s': %w
- error creating directory '%s': %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/ca93b916a2bf01ff.
Report an issue: GitHub.