{"record":{"id":"ebd56b5cdaed18c3","repo":"micro-editor/micro","slug":"error-s-does-not-exist-defaulting-to-s","errorCode":null,"errorMessage":"Error: %s does not exist. Defaulting to %s.","messagePattern":"Error: (.+?) does not exist\\. Defaulting to (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/config/config.go","lineNumber":37,"sourceCode":"\tif microHome == \"\" {\n\t\t// The user has not set $MICRO_CONFIG_HOME so we'll try $XDG_CONFIG_HOME\n\t\txdgHome := os.Getenv(\"XDG_CONFIG_HOME\")\n\t\tif xdgHome == \"\" {\n\t\t\t// The user has not set $XDG_CONFIG_HOME so we should act like it was set to ~/.config\n\t\t\thome, err := homedir.Dir()\n\t\t\tif err != nil {\n\t\t\t\treturn errors.New(\"Error finding your home directory\\nCan't load config files: \" + err.Error())\n\t\t\t}\n\t\t\txdgHome = filepath.Join(home, \".config\")\n\t\t}\n\n\t\tmicroHome = filepath.Join(xdgHome, \"micro\")\n\t}\n\tConfigDir = microHome\n\n\tif len(flagConfigDir) > 0 {\n\t\tif _, err := os.Stat(flagConfigDir); os.IsNotExist(err) {\n\t\t\te = errors.New(\"Error: \" + flagConfigDir + \" does not exist. Defaulting to \" + ConfigDir + \".\")\n\t\t} else {\n\t\t\tConfigDir = flagConfigDir\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// Create micro config home directory if it does not exist\n\t// This creates parent directories and does nothing if it already exists\n\terr := os.MkdirAll(ConfigDir, os.ModePerm)\n\tif err != nil {\n\t\treturn errors.New(\"Error creating configuration directory: \" + err.Error())\n\t}\n\n\treturn e\n}\n","sourceCodeStart":19,"sourceCodeEnd":53,"githubUrl":"https://github.com/micro-editor/micro/blob/1c8b82b32e408a5faf340039ed92d5266bea3293/internal/config/config.go#L19-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"Wrapper scripts/desktop launchers passing a config dir before creating it, WSL/remote setups where ~ differs between contexts, and typos in the flag value.","solutions":["Create the directory first: mkdir -p /path/to/config && micro -config-dir /path/to/config.","Use an absolute path (expand ~ yourself) — the flag is used verbatim.","If you wanted a throwaway config, point -config-dir at an empty dir you made (e.g. $(mktemp -d)).","If the fallback is fine, simply ignore the warning — micro continues with the default location."],"exampleFix":"# before:\nmicro -config-dir ~/editor-configs/main   # dir absent -> warning, falls back\n\n# after:\nmkdir -p ~/editor-configs/main && micro -config-dir ~/editor-configs/main","handlingStrategy":"validation","validationCode":"func usableConfigDir(path string) bool {\n    if path == \"\" {\n        return true // flag not used\n    }\n    fi, err := os.Stat(path)\n    return err == nil && fi.IsDir()\n}\n\nif !usableConfigDir(flagDir) { /* create it first: os.MkdirAll(flagDir, 0o755) */ }","typeGuard":"func isExistingDir(path string) bool {\n    fi, err := os.Stat(path)\n    return err == nil && fi.IsDir()\n}","tryCatchPattern":"if err := config.InitConfigDir(flagDir); err != nil {\n    if strings.Contains(err.Error(), \"does not exist. Defaulting to\") {\n        // acceptable: micro fell back to the default config dir; continue\n    }\n}","preventionTips":["Expand ~ and use absolute paths in -config-dir; the flag value is taken literally.","Create the config dir in your setup script before first launch (mkdir -p).","Prefer MICRO_CONFIG_HOME env over the flag in wrappers so typos surface earlier."],"tags":["config","cli-flags","filesystem","startup"],"backgroundTag":null,"analyzedSha":"1c8b82b32e408a5faf340039ed92d5266bea3293","analyzedAt":"2026-08-15T20:01:45.134Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}