{"record":{"id":"1f4d8bcab6934e46","repo":"JanDeDobbeleer/oh-my-posh","slug":"err-executing-s-with-v","errorCode":null,"errorMessage":"err executing %s with %v","messagePattern":"err executing (.+?) with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/segments/language.go","lineNumber":449,"sourceCode":"func (l *Language) runCommand(command *cmd) (string, error) {\n\tif command.getVersion == nil {\n\t\tif !l.env.HasCommand(command.executable) {\n\t\t\treturn \"\", errors.New(noVersion)\n\t\t}\n\n\t\tcacheKey, cacheable := l.versionCacheKey(command)\n\t\tif cacheable {\n\t\t\tif cached, found := cache.Device.Get[string](cacheKey); found {\n\t\t\t\tlog.Debugf(\"using cached version output for %s\", command.executable)\n\t\t\t\treturn cached, nil\n\t\t\t}\n\t\t}\n\n\t\tversionStr, err := l.env.RunCommandWithEnv(command.executable, command.envs, command.args...)\n\n\t\tif exitErr, ok := err.(*runtime.CommandError); ok {\n\t\t\tl.exitCode = exitErr.ExitCode\n\t\t\treturn \"\", fmt.Errorf(\"err executing %s with %v\", command.executable, command.args)\n\t\t}\n\n\t\t// Success only: a failed run (a non-CommandError err, or one the\n\t\t// caller above already turned into an early return) never gets\n\t\t// cached, so a transient failure cannot pin a bad result for a week.\n\t\tif err == nil && cacheable {\n\t\t\tcache.Device.Set(cacheKey, versionStr, cache.ONEWEEK)\n\t\t}\n\n\t\treturn versionStr, nil\n\t}\n\n\tversionStr, err := command.getVersion()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif versionStr == \"\" {","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/language.go#L431-L467","documentation":"The language segment executed a version command and the process exited with a non-zero exit code (wrapped as runtime.CommandError). oh-my-posh records the exit code and returns 'err executing <executable> with <args>' instead of a version.","triggerScenarios":"Calling `RunCommandWithEnv` on an executable that exists but exits non-zero: the tool crashes, a required arg is wrong for that tool version, a license/telemetry prompt fails in a non-interactive context, or the shim resolves to a broken install.","commonSituations":"Removed or renamed flags (e.g. `--version` unsupported on some binary); node/python version managers printing errors; corrupted toolchain after an OS upgrade; running the prompt inside an environment where the tool needs env vars that aren't set (command.envs incomplete).","solutions":["Run the exact command with the same args manually and check the exit code and stderr output","Fix the underlying tool installation (reinstall, repair PATH resolution, remove broken shim)","Adjust the segment's command args/envs in the theme config to match the installed tool","If the tool genuinely lacks a version flag, configure a different command for the segment"],"exampleFix":"// before: tool exits 1 because --version is unsupported\n\"commands\": [{ \"executable\": \"java\", \"args\": [\"--version\"] }]\n// after: use the flag the installed JDK supports\n\"commands\": [{ \"executable\": \"java\", \"args\": [\"-version\"] }]","handlingStrategy":"try-catch","validationCode":"// verify the tool runs cleanly before relying on the segment\nexec.Command(\"node\", \"--version\").Run() // check err and exit code","typeGuard":null,"tryCatchPattern":"// segment already captures the exit code; treat the error as terminal\nif _, err := segment.SetVersion(); err != nil {\n    // hide the segment, don't retry\n    renderFallback()\n}","preventionTips":["Manually run the exact command+args from the theme config after tool installs","Reinstall tools whose upgrade may have broken flags","Avoid wrappers that exit non-zero in non-interactive shells","Log stderr of failing commands to spot license/prompt failures"],"tags":["go","command-execution","exit-code","language-segment"],"backgroundTag":"command-exited-nonzero","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}