{"record":{"id":"d694f59955d66b47","repo":"charmbracelet/glow","slug":"unable-to-run-command-w","errorCode":null,"errorMessage":"unable to run command: %w","messagePattern":"unable to run command: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config_cmd.go","lineNumber":48,"sourceCode":"\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)\n\t\t}\n\t}\n\n\tif ext := path.Ext(configFile); ext != \".yaml\" && ext != \".yml\" {\n\t\treturn fmt.Errorf(\"'%s' is not a supported configuration type: use '%s' or '%s'\", ext, \".yaml\", \".yml\")\n\t}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/config_cmd.go#L30-L66","documentation":"After editor.Cmd successfully builds the command, glow wires os.Stdin/Stdout/Stderr to it and calls c.Run(). This error wraps any failure from that execution: the process could not be spawned, or it exited with a non-zero status. The config file path was already validated (ensureConfigFile ran first), so this is purely about the editor process.","triggerScenarios":"EDITOR points to a binary that disappeared between lookup and exec (or lookup returned it despite PATH issues); the editor exits non-zero — e.g. quitting vim with :cq; GUI editors like VS Code launched as EDITOR=code without --wait exit immediately or misbehave without a TTY; exec permission denied on the editor binary.","commonSituations":"EDITOR=\"code\" or EDITOR=\"subl\" without a wait flag; scripts running glow config where stdout is not a terminal; editors that abort when the file is a symlink into a read-only path.","solutions":["Confirm the exact editor command works standalone with a file argument","Use a terminal editor (vim, nano) or add a wait flag: EDITOR=\"code --wait\"","If the editor aborted, fix the underlying cause it printed to stderr and rerun glow config"],"exampleFix":"# before\n$ EDITOR=code glow config   # exits/renders nothing useful\n\n# after\n$ EDITOR=\"code --wait\" glow config\n# or\n$ EDITOR=vim glow config","handlingStrategy":"try-catch","validationCode":"// smoke-test the exact invocation glow will use\nc := exec.Command(editorBin, \"/tmp/probe.yml\")\nc.Stdin, c.Stdout, c.Stderr = os.Stdin, os.Stdout, os.Stderr\nif err := c.Run(); err != nil {\n\tlog.Fatalf(\"editor smoke test failed: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := c.Run(); err != nil {\n\tvar exitErr *exec.ExitError\n\tif errors.As(err, &exitErr) {\n\t\t// editor ran but exited non-zero (e.g. vim :cq) — ask the user, keep the file\n\t\treturn fmt.Errorf(\"editor exited with status %d; rerun 'glow config' when ready\", exitErr.ExitCode())\n\t}\n\t// spawn failure (missing binary, permissions, no TTY)\n\treturn fmt.Errorf(\"unable to run command: %w\", err)\n}","preventionTips":["Use a blocking terminal editor (vim/nano) or add a wait flag for GUIs: EDITOR='code --wait'","Run glow config from a real TTY so the editor can take over stdin/stdout","Distinguish ExitError (user aborted) from spawn errors — only the latter indicates a broken EDITOR value"],"tags":["config","editor","process","exec"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}