fix(tether): resolve a working Python 3 instead of hardcoding python3 - #980
Open
AmirF194 wants to merge 1 commit into
Open
fix(tether): resolve a working Python 3 instead of hardcoding python3#980AmirF194 wants to merge 1 commit into
AmirF194 wants to merge 1 commit into
Conversation
On Windows/Git Bash, python3 is commonly the Microsoft Store App Installer redirector shim: it is on PATH, so `command -v python3` succeeds, but it exits non-zero with no output on every invocation. Every call site in lib.sh, tether.sh, and hooks/tether-notify.sh invoked python3 directly with no exit-code check (this file deliberately runs without `set -e`), so the shim's failure was silent: helpers returned empty strings and execution limped forward into misleading downstream errors instead of stopping. Add t_python, which resolves and memoizes a Python 3 that actually executes (tries $E2A_PYTHON, then python3, then python, verifying each by running it, not just locating it) and route all ~20 python3 call sites through it. Add a _selftest check that reproduces the broken-shim scenario and confirms both the fallback and the loud-failure path. Refs tokencanopy#367
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Every
python3call site inlib.sh,tether.sh, andhooks/tether-notify.shinvokes the interpreter directly with noexit-code check. That is deliberate for this file (it runs without
set -e), so the assumption baked into every call site is thatpython3either runs or is entirely absent from PATH.On Windows/Git Bash that assumption is wrong:
python3is commonlythe Microsoft Store App Installer redirector shim. It sits on PATH,
so
command -v python3succeeds, but it exits non-zero with nooutput on every real invocation. Every helper that shells out to it
(
t_now_iso,t_state_get/t_state_set,t_duration_to_expiry,and about 15 others) silently returns an empty string instead of a
real value, and the caller limps forward on that empty data instead
of stopping.
Fix
Added
t_python(lib.sh), which resolves and memoizes a Python 3that actually executes: tries
$E2A_PYTHON, thenpython3, thenpython, verifying each candidate by running it rather than justlocating it on PATH. All ~20 call sites now go through it. When no
candidate works,
t_pythonprints a clear diagnostic to stderrinstead of failing silently.
Verification
python3that exits 49 with no output) against unmodifiedmain(
9d7d86f):t_now_isoreturned empty andt_state_setwrote nostate file, silently. The new
_selftestcheck covering this,run against the same container, fails on
mainand passes onthis branch, both with the fallback
pythonpresent and with noworking interpreter anywhere (loud stderr diagnostic instead).
tether.sh _selftest(this repo's test suite for the skill,run by the
tetherCI job) green on the branch.packagejob gates (node --testplugin contracttests,
node scripts/validate-plugin.mjs) green after bumping thee2a-labs plugin version in
plugin.meta.jsonper its version-bumpcheck.
available here). The Docker repro reproduces the shim's exact
observable behavior (on PATH, exits non-zero, no output), not the
OS itself.
This covers item 1 of #367 only (the interpreter-resolution fix);
items 2-5 of that issue are separate onboarding/UX proposals already
partially superseded by the CLI rewrite in #369, out of scope here.
Refs #367