JanDeDobbeleer/oh-my-posh · warning

executable at %s is not a pyenv shim

Error message

executable at %s is not a pyenv shim

What it means

The python segment supports pyenv-managed interpreters. pyenvVersion first locates the python/python3 executable and then verifies it lives under $PYENV_ROOT (a pyenv 'shim'). This error is thrown when a python executable exists on PATH but is not inside PYENV_ROOT — so the active python is not managed by pyenv and `pyenv version-name` would not correspond to it.

Source

Thrown at src/segments/python.go:184

	return true
}

func (p *Python) pyenvVersion() (string, error) {
	// Use `pyenv root` instead of $PYENV_ROOT?
	// Is our Python executable at $PYENV_ROOT/bin/python ?
	// Should p.env expose command paths?
	cmdPath := p.env.CommandPath(pythonToolName)
	if cmdPath == "" {
		cmdPath = p.env.CommandPath(python3ToolName)
	}

	if cmdPath == "" {
		return "", errors.New("no python executable found")
	}

	pyEnvRoot := p.env.Getenv("PYENV_ROOT")
	if pyEnvRoot == "" || !strings.HasPrefix(cmdPath, pyEnvRoot) {
		return "", fmt.Errorf("executable at %s is not a pyenv shim", cmdPath)
	}

	// pyenv version-name will return current version or virtualenv
	cmdOutput, err := p.env.RunCommand("pyenv", "version-name")
	if err != nil {
		return "", err
	}

	versionString, _, found := strings.Cut(cmdOutput, ":")
	if !found || versionString == "" {
		return "", errors.New("no pyenv version-name found")
	}

	// $PYENV_ROOT/versions + versionString (symlinks resolved) == $PYENV_ROOT/versions/(version)[/envs/(virtualenv)]
	realPath, err := p.env.ResolveSymlink(filepath.Join(pyEnvRoot, "versions", versionString))
	if err != nil {
		return "", err
	}

View on GitHub (pinned to 0976794618)

Solutions

  1. Ensure pyenv shims are on PATH: add `eval "$(pyenv init -)"` (and pyenv-virtualenv init) to your shell rc
  2. Set PYENV_ROOT if pyenv is installed in a non-default location (e.g. export PYENV_ROOT="$HOME/.pyenv") and add $PYENV_ROOT/shims to PATH
  3. Run `which python` / `which python3` and confirm it resolves to $PYENV_ROOT/shims/python
  4. If you don't use pyenv, the segment falls back to other version detection — check that your display_mode/version detection config matches your setup

Example fix

// before (~/.zshrc)
eval "$(pyenv init --path)"  # shims incomplete / PYENV_ROOT unset
// after
export PYENV_ROOT="$HOME/.pyenv"
case "$PATH" in *"$PYENV_ROOT/shims"*) ;; *) export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH";; esac
eval "$(pyenv init -)"
Defensive patterns

Strategy: validation

Validate before calling

[[ -n "$PYENV_ROOT" ]] && which python | grep -q "$PYENV_ROOT" && echo "pyenv shims active" || echo "python not pyenv-managed"

Prevention

When it happens

Trigger: PYENV_ROOT is unset, or the resolved CommandPath for python/python3 points outside PYENV_ROOT (e.g. /usr/bin/python3, a Homebrew python, or a manually activated venv) while the segment's version logic tries the pyenv path.

Common situations: pyenv installed but PATH shims not set up (or removed), python installed via system package manager shadowing pyenv shims, PYENV_ROOT customized but shims in the default ~/.pyenv/shims, or a virtualenv activated by another tool taking precedence on PATH.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/e1e228fe01edbf13. Report an issue: GitHub.