abiosoft/colima · warning
invalid directory: %w
Error message
invalid directory: %w
What it means
defaultWatcher.Watch sanitizes every directory it is about to register with util.CleanPath (env expansion, ~ expansion, then absolute-path enforcement). A path that is not absolute after expansion fails as 'invalid directory: relative paths not supported for mount ...'. The error returns from Watch and reaches the user only via the logged 'error running watcher' (error 105), so watching silently degrades for the whole volume set.
Source
Thrown at daemon/process/inotify/watch.go:36
// An error is returned when the watcher can not be started in background.
//
// The watcher terminates on fatal error or when ctx is done.
Watch(ctx context.Context, dirs []string, c chan<- modEvent) error
}
type defaultWatcher struct {
log *logrus.Entry
}
// Watch implements dirWatcher
func (d *defaultWatcher) Watch(ctx context.Context, dirs []string, mod chan<- modEvent) error {
log := d.log
c := make(chan notify.EventInfo, 1)
for _, dir := range dirs {
dir, err := util.CleanPath(dir)
if err != nil {
return fmt.Errorf("invalid directory: %w", err)
}
err = notify.Watch(dir+"...", c, notify.Write)
if err != nil {
return fmt.Errorf("error watching directory recursively '%s': %w", dir, err)
}
}
go func(ctx context.Context, c chan notify.EventInfo, mod chan<- modEvent) {
for {
select {
case <-ctx.Done():
notify.Stop(c)
log.Trace("stopping watcher")
if err := ctx.Err(); err != nil {
log.Trace(fmt.Errorf("error found in ctx: %w", err))
return
}View on GitHub (pinned to c3a5f9184d)
Solutions
- locate the offending path in the wrapped 'invalid directory' message and fix the container's -v mount to an absolute path
- restart colima after fixing so the volume list is rebuilt
- keep container mount sources within the host directories already configured as colima mounts
Defensive patterns
Strategy: validation
Validate before calling
for _, dir := range dirs {
if p, err := util.CleanPath(dir); err != nil || !filepath.IsAbs(p) {
continue // skip unwatchable entries instead of failing the whole set
}
watchable = append(watchable, p)
} Try / catch
if err := watcher.Watch(ctx, vols, mod); err != nil {
if strings.Contains(err.Error(), "invalid directory") {
// a volume Source did not sanitize; expect refresh on next poll
}
} Prevention
- mount container volumes with absolute host paths only
- keep sources inside directories already configured as colima mounts
- remember the daemon runs as root: '~' expands differently than in your shell
When it happens
Trigger: a container volume Source that does not resolve to an absolute path; '~'-relative sources expanded against the root daemon's HOME (/var/root) instead of the user's; env vars unset in the daemon's sterile environment.
Common situations: containers mounting unusual paths; HOME differences between the interactive shell and the privileged daemon process.
Related errors
- error sanitising mount path for inotify: %w
- error watching directory recursively '%s': %w
- relative paths not supported for mount '%s'
- error persisting runtime settings: %w
- error persisting kubernetes settings: %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/c3faade945a2359e.
Report an issue: GitHub.