cool-easter-32542
08/12/2023, 6:53 AMpants tailor :: or pants test :: explode with an opaque error:
IntrinsicError: Failed to read link "/Users/huon/tmp/pants-venv/venv/bin/python": Absolute symlink: "/Users/huon/.pyenv/versions/3.9.10/bin/python"
This is particularly confusing for onboarding: many people using Python will be used to creating venvs by default, and they may not have it ignored, especially while just experimenting with Pants for the first time.
The error message could be improved. On two levels:
1. generically, for any absolute symlink: the error message could be more specific about these symlinks being a problem, why, and how to fix (e.g. remove, or ignore)
2. for this common venv case, Pants could have heuristics to detect venv-like paths (e.g. containing a folder name like venv or .venv, or a link like .../bin/python) and suggest things like removing the venv (not necessary with pants) and/or ignoring it
Some workarounds
1. remove the venv(s) entirely
2. add the venv(s) to .gitignore (adjacent to pants.toml)
3. add the venv(s) to pants_ignore in pants.toml, e.g.
[GLOBAL]
...
pants_ignore.add = ["venv"]
Reproducer:
cd $(mktemp -d)
cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.16.0"
backend_packages = ["pants.backend.python"]
[anonymous-telemetry]
enabled = false
EOF
python -m venv venv
pants tailor ::
Output:
15:09:44.41 [INFO] Initializing scheduler...
15:09:48.47 [INFO] Scheduler initialized.
15:09:48.49 [ERROR] 1 Exception encountered:
Engine traceback:
in `tailor` goal
IntrinsicError: Failed to read link "/private/var/folders/sv/vd266m4d4lvctgs2wpnhjs9w0000gn/T/tmp.Lw7I6aDt/venv/bin/python": Absolute symlink: "/Users/huon/.pyenv/versions/3.9.10/bin/python"
Pants version
2.16.0
OS
macOS
Additional info
https://pantsbuild.slack.com/archives/C046T6T9U/p1691744178310219
pantsbuild/pants