Skip to content

fix(cli): re-exec the hash seed pin as a module, not by replaying argv[0] - #3780

Closed
ayushcodes10 wants to merge 3 commits into
Graphify-Labs:v8from
ayushcodes10:fix-3779-hashseed-reexec-argv0-windows
Closed

ayushcodes10 wants to merge 3 commits into
Graphify-Labs:v8from
ayushcodes10:fix-3779-hashseed-reexec-argv0-windows

Conversation

@ayushcodes10

Copy link
Copy Markdown
Contributor

Fixes #3779 — a regression in my own #3743 (issue #3641), reported within a day of the 0.9.66 release shipping. Sorry about that.

_pin_hash_seed_if_needed re-execs like this:

os.execvpe(sys.executable, [sys.executable, *sys.argv], {**os.environ, "PYTHONHASHSEED": "0"})

This replays sys.argv[0] as the script path for the interpreter to run. That works for a POSIX console-script wrapper or a python -m graphify invocation — both real, runnable Python content — but not for a uv/pip/pipx console-script launcher on Windows, which installs as a native .exe stub with no such content. The interpreter has nothing to open, and every command this function touches (update/extract/cluster-only/label) failed outright with can't open file the moment it tried to pin the seed.

Fix (the issue's own suggestion, which is correct and minimal): re-exec via -m graphify instead, which never depends on argv[0] being anything runnable at all:

os.execvpe(sys.executable, [sys.executable, "-m", "graphify", *sys.argv[1:]], {**os.environ, "PYTHONHASHSEED": "0"})

This also now matches the exact invocation shape the existing end-to-end test for this function (test_update_still_runs_end_to_end_with_hashseed_unset) was already exercising.

Verified the failure mode empirically before touching anything — simulated a non-Python launcher stub path as argv[0] and confirmed it broke pre-fix (can't open file) and is fixed post-fix. Updated the existing probe assertions to the new argv shape and added a dedicated regression test that drives the probe with a launcher stub path that isn't even a real file, confirming the fix no longer depends on it being runnable — the exact shape of the Windows uv-launcher scenario. Full suite is green aside from 16 pre-existing failures in the newly-added Erlang/R/Solidity/VB.NET extractor tests, caused by their optional grammar packages not being installed in my dev environment — unrelated to this change (confirmed via python -c "import tree_sitter_r" etc. all failing with ModuleNotFoundError, and confirmed these packages weren't needed by any branch cut before the 0.9.66 release landed).

🤖 Generated with Claude Code

https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh

ayushcodes10 and others added 3 commits September 23, 2026 12:16
The previous form replayed sys.argv[0] as the script path to run,
which happens to work for a POSIX console script wrapper or a python
dash m invocation, both of which are real, runnable Python content.
It does not work for a uv, pip, or pipx console script launcher on
Windows, which installs as a native executable stub with no such
content, so the interpreter has nothing to open and every affected
command failed outright the moment it tried to pin the seed.

Re execing through the module flag instead never depends on argv[0]
being anything runnable at all, so a launcher stub that is not even a
real file no longer matters, and this now matches the exact
invocation shape the end to end test for this function already
exercised and proved working.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
The existing probe assertions now expect the module flag form. A new
test drives the probe with a launcher stub path that is not even a
real file in place of argv zero, confirming the fix no longer depends
on it being anything runnable, the exact shape of the Windows uv
launcher regression this closes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.67 (on PyPI). Cherry-picked with authorship preserved. Thanks @ayushcodes10! This fixes the Windows regression the 0.9.66 hash-seed pin introduced — the -m graphify re-exec is exactly right.

@safishamsi safishamsi closed this Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: update/query fail with "can't open file" after PYTHONHASHSEED re-exec (uv tool install)

2 participants