bin/install builds the wrong version when python3 resolves to an asdf shim
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- build-system
Research direction
Start by reading the Python entry point bin/install and how it reads ASDF_INSTALL_VERSION and ASDF_INSTALL_PATH; the issue identifies both variables as overwritten when python3 resolves to an asdf shim. Compare the proposed shell wrapper approach with resolving a non-shim interpreter. Done means asdf install php 8.5.12 builds that PHP version into its PHP install path when Python is managed by asdf.
Written by the indexing model from the issue text.
Description
Summary
Since the php-build rewrite (#200), bin/install is a Python script started via
#!/usr/bin/env python3. If python3 on PATH is an asdf shim (i.e. the user
manages Python with asdf-python and has a version set), the shim overwrites
ASDF_INSTALL_VERSION and ASDF_INSTALL_PATH with the Python tool's values
before the script runs. The plugin then tries to build PHP using the Python
version and install path.
Steps to reproduce
- Manage Python with asdf and set a version, e.g.
python 3.15.2in
~/.tool-versions. asdf install php 8.5.12
Actual result
Building PHP 3.15.2...
[Error]: Definition 3.15.2 not found.
asdf-php: Command ('~/.asdf/plugins/php/vendor/php-build/bin/php-build', '3.15.2', '~/.asdf/installs/python/3.15.2') returned non-zero exit status 127.
Expected result
PHP 8.5.12 is built into ~/.asdf/installs/php/8.5.12.
Root cause
Running a command through an asdf shim sets ASDF_INSTALL_VERSION /
ASDF_INSTALL_PATH for the shimmed tool, and those values reach the exec'd
process. Minimal check (asdf 0.20.0):
ASDF_INSTALL_VERSION=8.5.12 ASDF_INSTALL_PATH=/x/php/8.5.12 ASDF_CUSTOM=8.5.12 \
python3 -c 'import os; print(os.environ["ASDF_INSTALL_VERSION"], os.environ["ASDF_INSTALL_PATH"], os.environ["ASDF_CUSTOM"])'
# -> 3.15.2 ~/.asdf/installs/python/3.15.2 8.5.12
ASDF_INSTALL_TYPE and unrelated variables are left untouched, so only the
version and path are corrupted.
Workaround
Put a non-shim python3 first on PATH only for the install, keeping the
rest of PATH (e.g. Homebrew's pkg-config) intact:
d=$(mktemp -d) && ln -s /usr/bin/python3 "$d/python3"
PATH="$d:$PATH" asdf install php 8.5.12
rm -r "$d"
(Prepending /usr/bin to PATH also avoids the shim, but it breaks builds that
rely on Homebrew's pkg-config / libraries on Linux.)
Possible fix
Keep bin/install as a small shell wrapper that captures the values before
any shim can run, e.g. into ASDF_PHP_INSTALL_VERSION / ASDF_PHP_INSTALL_PATH,
and have the Python code read those. Alternatively, resolve a python3 that is
not under ${ASDF_DATA_DIR:-$HOME/.asdf}/shims.
Environment
- asdf 0.20.0 (Homebrew on Linux)
- asdf-php at 8c51982
- asdf-python with
python 3.15.2set globally - Ubuntu 26.04.1 LTS on WSL2 (kernel 6.18.58)
- Dominant language
- Python
- Stars
- 255
- Forks
- 118
- Avg merge
- 42m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from asdf-community/asdf-php
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
asdf-community/asdf-php#145 · 3 comments · 3 reactions ·
-
Install PIE (PHP's new extension installer) by defaultMay be free again @Rusydy claimed this 348 days ago, and no pull request is open. Open
asdf-community/asdf-php#190 · 2 reactions · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
asdf-community/asdf-php#183 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
asdf-community/asdf-php#181 · 10 comments · 3 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
asdf-community/asdf-php#180 · 1 comment · 1 reaction ·
All issues in asdf-community/asdf-php
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
btclib-org/btclib-wallet#872 ·
Maintainers usually reply within 1 day
-
[Bug]: Scheduled returns scan all accepted minion keys causing extreme loadPossibly taken A pull request linked to this issue is open or already merged. Openbug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
saltstack/salt#70789 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
btclib-org/btclib#3093 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
patrickballard/wheelgap#269 ·
-
priority: low python
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
LearningCircuit/local-deep-research#8635 ·
Maintainers usually reply within 1 day