micro-editor/micro · warning

Error: %s does not exist. Defaulting to %s.

Error message

Error: %s does not exist. Defaulting to %s.

What it means

Warning-style error from InitConfigDir when the -config-dir command-line flag points to a path that does not exist (os.Stat returns IsNotExist). Micro keeps the previously computed default ConfigDir and returns this message noting the fallback; the default directory is then created if missing.

Source

Thrown at internal/config/config.go:37

	if microHome == "" {
		// The user has not set $MICRO_CONFIG_HOME so we'll try $XDG_CONFIG_HOME
		xdgHome := os.Getenv("XDG_CONFIG_HOME")
		if xdgHome == "" {
			// The user has not set $XDG_CONFIG_HOME so we should act like it was set to ~/.config
			home, err := homedir.Dir()
			if err != nil {
				return errors.New("Error finding your home directory\nCan't load config files: " + err.Error())
			}
			xdgHome = filepath.Join(home, ".config")
		}

		microHome = filepath.Join(xdgHome, "micro")
	}
	ConfigDir = microHome

	if len(flagConfigDir) > 0 {
		if _, err := os.Stat(flagConfigDir); os.IsNotExist(err) {
			e = errors.New("Error: " + flagConfigDir + " does not exist. Defaulting to " + ConfigDir + ".")
		} else {
			ConfigDir = flagConfigDir
			return nil
		}
	}

	// Create micro config home directory if it does not exist
	// This creates parent directories and does nothing if it already exists
	err := os.MkdirAll(ConfigDir, os.ModePerm)
	if err != nil {
		return errors.New("Error creating configuration directory: " + err.Error())
	}

	return e
}

View on GitHub (pinned to 1c8b82b32e)

Solutions

  1. Create the directory first: mkdir -p /path/to/config && micro -config-dir /path/to/config.
  2. Use an absolute path (expand ~ yourself) — the flag is used verbatim.
  3. If you wanted a throwaway config, point -config-dir at an empty dir you made (e.g. $(mktemp -d)).
  4. If the fallback is fine, simply ignore the warning — micro continues with the default location.

Example fix

# before:
micro -config-dir ~/editor-configs/main   # dir absent -> warning, falls back

# after:
mkdir -p ~/editor-configs/main && micro -config-dir ~/editor-configs/main
Defensive patterns

Strategy: validation

Validate before calling

func usableConfigDir(path string) bool {
    if path == "" {
        return true // flag not used
    }
    fi, err := os.Stat(path)
    return err == nil && fi.IsDir()
}

if !usableConfigDir(flagDir) { /* create it first: os.MkdirAll(flagDir, 0o755) */ }

Type guard

func isExistingDir(path string) bool {
    fi, err := os.Stat(path)
    return err == nil && fi.IsDir()
}

Try / catch

if err := config.InitConfigDir(flagDir); err != nil {
    if strings.Contains(err.Error(), "does not exist. Defaulting to") {
        // acceptable: micro fell back to the default config dir; continue
    }
}

Prevention

When it happens

Trigger: Launching `micro -config-dir ~/missing-dir` where the directory is absent, a relative path that resolves against a different cwd, or quoting/tilde-expansion mistakes (some launchers do not expand ~). Note the stat at internal/config/config.go:37 only catches non-existence; a permission problem on an existing dir is not caught here.

Common situations: Wrapper scripts/desktop launchers passing a config dir before creating it, WSL/remote setups where ~ differs between contexts, and typos in the flag value.

Related errors


AI-assisted analysis of micro-editor/micro@1c8b82b32e (2026-08-15). Data as JSON: /api/errors/ebd56b5cdaed18c3. Report an issue: GitHub.