{"record":{"id":"54e3d0ae230a7431","repo":"JanDeDobbeleer/oh-my-posh","slug":"no-pyenv-version-name-found","errorCode":null,"errorMessage":"no pyenv version-name found","messagePattern":"no pyenv version-name found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/segments/python.go","lineNumber":195,"sourceCode":"\n\tif cmdPath == \"\" {\n\t\treturn \"\", errors.New(\"no python executable found\")\n\t}\n\n\tpyEnvRoot := p.env.Getenv(\"PYENV_ROOT\")\n\tif pyEnvRoot == \"\" || !strings.HasPrefix(cmdPath, pyEnvRoot) {\n\t\treturn \"\", fmt.Errorf(\"executable at %s is not a pyenv shim\", cmdPath)\n\t}\n\n\t// pyenv version-name will return current version or virtualenv\n\tcmdOutput, err := p.env.RunCommand(\"pyenv\", \"version-name\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tversionString, _, found := strings.Cut(cmdOutput, \":\")\n\tif !found || versionString == \"\" {\n\t\treturn \"\", errors.New(\"no pyenv version-name found\")\n\t}\n\n\t// $PYENV_ROOT/versions + versionString (symlinks resolved) == $PYENV_ROOT/versions/(version)[/envs/(virtualenv)]\n\trealPath, err := p.env.ResolveSymlink(filepath.Join(pyEnvRoot, \"versions\", versionString))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// ../versions/(version)[/envs/(virtualenv)]\n\tshortPath, err := filepath.Rel(filepath.Join(pyEnvRoot, \"versions\"), realPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// override virtualenv if pyenv set one\n\tparts := strings.SplitN(shortPath, string(filepath.Separator), 4)\n\tif len(parts) > 2 && p.canUseVenvName(parts[2]) {\n\t\tp.Venv = parts[2]","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/python.go#L177-L213","documentation":"The python segment found a python executable inside PYENV_ROOT and ran `pyenv version-name`, but the command's output could not be split into a non-empty version string before the ':' separator. This means pyenv itself failed to report the active version (empty or malformed output).","triggerScenarios":"`pyenv version-name` returns empty or unexpected output — no version selected anywhere (no .python-version file, no PYENV_VERSION, no global version set), a broken pyenv installation, or output format differing from what strings.Cut(\":\") expects.","commonSituations":"pyenv installed but never configured with `pyenv global`, shims resolving inside PYENV_ROOT while version selection files are missing, or corrupted ~/.pyenv/version.","solutions":["Run `pyenv global 3.x.y` (or create a .python-version in the project) so version-name has something to report.","Run `pyenv version-name` manually in the affected directory and check its output is a plain version string.","Reinstall/repair pyenv if version-name errors or prints nothing.","Verify PYENV_ROOT points at the pyenv installation that actually manages your shims."],"exampleFix":"# before\n$ pyenv version-name\n(empty)\n# after\n$ pyenv global 3.12.1\n$ pyenv version-name\n3.12.1","handlingStrategy":"validation","validationCode":"out=$(pyenv version-name 2>/dev/null)\nif [ -z \"$out\" ]; then\n  echo \"pyenv returned no version: run 'pyenv global <ver>' or set .python-version\"\nfi","typeGuard":null,"tryCatchPattern":"version, err := p.pyenvVersion()\nif err != nil {\n  if err.Error() == \"no pyenv version-name found\" {\n    return \"\" // pyenv not configured — fall back to plain python tooling\n  }\n  return \"\", err\n}","preventionTips":["Always set a pyenv version: `pyenv global X.Y.Z` and/or a project .python-version.","Sanity-check `pyenv version-name` output in directories where the prompt misbehaves.","Keep pyenv and its shims healthy (reinstall if version-name emits nothing).","Override the tooling option to fall back to plain python/python3 when pyenv is unconfigured."],"tags":["python","pyenv","version","toolchain"],"backgroundTag":"toolchain-version-lookup-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}