{"record":{"id":"0698a1c0e98eb55a","repo":"charmbracelet/glow","slug":"unable-to-set-config-file-w","errorCode":null,"errorMessage":"unable to set config file: %w","messagePattern":"unable to set config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config_cmd.go","lineNumber":42,"sourceCode":"# show all files, including hidden and ignored.\nall: false\n`\n\nvar configCmd = &cobra.Command{\n\tUse:     \"config\",\n\tHidden:  false,\n\tShort:   \"Edit the glow config file\",\n\tLong:    paragraph(fmt.Sprintf(\"\\n%s the glow config file. We’ll use EDITOR to determine which editor to use. If the config file doesn't exist, it will be created.\", keyword(\"Edit\"))),\n\tExample: paragraph(\"glow config\\nglow config --config path/to/config.yml\"),\n\tArgs:    cobra.NoArgs,\n\tRunE: func(*cobra.Command, []string) error {\n\t\tif err := ensureConfigFile(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tc, err := editor.Cmd(\"Glow\", configFile)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to set config file: %w\", err)\n\t\t}\n\t\tc.Stdin = os.Stdin\n\t\tc.Stdout = os.Stdout\n\t\tc.Stderr = os.Stderr\n\t\tif err := c.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to run command: %w\", err)\n\t\t}\n\n\t\tfmt.Println(\"Wrote config file to:\", configFile)\n\t\treturn nil\n\t},\n}\n\nfunc ensureConfigFile() error {\n\tif configFile == \"\" {\n\t\tconfigFile = viper.GetViper().ConfigFileUsed()\n\t\tif err := os.MkdirAll(filepath.Dir(configFile), 0o755); err != nil { //nolint:gosec\n\t\t\treturn fmt.Errorf(\"could not write configuration file: %w\", err)","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/config_cmd.go#L24-L60","documentation":"The glow config command uses charmbracelet/editor's editor.Cmd(\"Glow\", configFile) to build an exec.Cmd for the user's editor (resolved from $EDITOR and similar sources). This error wraps the failure to construct that command, before anything is spawned — typically because no usable editor could be resolved. The editor binary itself has not run yet when this fires.","triggerScenarios":"Running glow config with EDITOR unset or empty in a minimal environment where no fallback editor is found; EDITOR pointing to a command name that cannot be resolved on PATH at lookup time; EDITOR containing a malformed value.","commonSituations":"Docker/scratch containers and CI shells with no EDITOR exported; headless servers where the dotfiles that set EDITOR were never installed; EDITOR set to an editor that was later uninstalled.","solutions":["Export a valid editor: export EDITOR=vim (or nano, micro)","Verify it resolves: command -v $EDITOR","Install a terminal editor if the image has none (apt-get install vim-tiny)","Alternatively edit the file directly: ${EDITOR:-vi} ~/.config/glow/glow.yml"],"exampleFix":"# before\n$ unset EDITOR; glow config\n# Error: unable to set config file: ...\n\n# after\n$ export EDITOR=vim && glow config","handlingStrategy":"validation","validationCode":"func resolveEditor() (string, error) {\n\ted := os.Getenv(\"EDITOR\")\n\tif ed == \"\" {\n\t\treturn \"\", errors.New(\"EDITOR is not set; export EDITOR=<editor> before 'glow config'\")\n\t}\n\tbin := strings.Fields(ed)[0]\n\tif _, err := exec.LookPath(bin); err != nil {\n\t\treturn \"\", fmt.Errorf(\"editor %q not found on PATH: %w\", bin, err)\n\t}\n\treturn ed, nil\n}\n\nif _, err := resolveEditor(); err != nil {\n\tlog.Fatal(err)\n}","typeGuard":null,"tryCatchPattern":"if err := configCmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"unable to set config file\") {\n\t\t// environment problem, not a glow bug: surface the EDITOR hint\n\t\tfmt.Fprintln(os.Stderr, \"set EDITOR, e.g. export EDITOR=vim, then retry\")\n\t\tos.Exit(1)\n\t}\n\treturn err\n}","preventionTips":["Export EDITOR in your shell profile (export EDITOR=vim) and keep a terminal editor installed","Verify with command -v \"$EDITOR\" before running glow config in scripts or fresh containers","In Dockerfiles: ENV EDITOR=vim plus a small editor package avoids this entirely"],"tags":["config","editor","environment","cli"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}