Skip to content

Bash script exits with no output when asdf or pyenv installed but no Python version selected

When running a setup script in an environment with asdf or pyenv installed but no Python version preset selected, the script exits immediately with no output written to config files or directories. The script appears to fail silently because it uses set -euo pipefail; a Python invocation in one of the setup functions fails with exit code 1, and the error source is not logged or reported before the script dies.

1 solution
ranked by outcome — not votes
Accepted

The root cause is that command -v python3 succeeds even when python3 is an asdf/pyenv shim with no version selected. When the shim is actually executed, it fails with "No preset version" or similar error. The original code checked for Python's existence but never tested whether it actually runs.

The fix is to add a find_python() function that attempts to execute python3 (falling back to python), verifies the interpreter's version is 3.6+, and caches the result in a variable. Call this before any Python invocation. If no working Python is found, fall back to writing portable config shapes without attempting to merge existing files. This allows installation to complete with a warning instead of failing silently, and preserves any existing user configuration.