Skip to content

fix(tools): make the scripts that start with a shebang executable - #9547

Merged
oneandonlydean merged 6 commits into
boykopovar:mainfrom
xXPBSXx:fix/tools-shebang-executable
Nov 24, 2026
Merged

oneandonlydean merged 6 commits into
boykopovar:mainfrom
xXPBSXx:fix/tools-shebang-executable

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

tools/check_compile.py, tools/nid_names.py, tools/stubgen.py and tools/unwrap_self.py start with #!/usr/bin/env python3 but were committed with mode 100644, so running them directly on Linux fails with Permission denied (exit code 126). They now have mode 100755. A new test, tool_script_modes, reads the index with git ls-files -s and fails for any tracked tools/*.py that has a shebang and a mode other than 100755 (it skips outside a Git checkout). The docs call the tools through python3, which is unaffected.

Tested

Windows 10, Python 3.12: python -I tools/tests/test_tool_script_modes.py fails on main with the four files listed (mode 100644) and passes with the change; test_test_registration.py passes and tools/check_test_registration.py --scripts accepts the new add_test (171 test scripts). tools/check_conventions.py --base upstream/main passes. Linux (WSL2, Ubuntu 24.04, a virtualised kernel, not bare-metal Linux): ./tools/<name>.py --help returns 126 on main and 0 for all four with the change; the new test passes. Not tested: macOS.

Order

Order with #6044: #6044 was closed on 24 October without being merged, so there is nothing to coordinate. main still registers these tests with plain add_test.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: tools: four scripts start with a shebang but are not executable #9546
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is narrowly scoped and the new mode regression is registered. I verified all four files are 100644 with a shebang on current main; in an isolated Git-index fixture the new test fails listing all four, then passes after they are staged as 100755. All four scripts execute from the PR snapshot. The current-main ancestry check passes and the branch overlap scan reports no duplicate tool changes. However, it cannot compare old-base #6044’s root CMakeLists.txt. Manual diff inspection shows #6044 rewrites the exact adjacent add_test(NAME trace_digest...) and add_test(NAME conventions_bom_shebang...) entries where this PR inserts tool_script_modes; the pairwise merge reports a root CMake conflict. The repository requires author coordination and a Depends on entry when shared lines need ordering. Please coordinate with #6044’s author and record the agreed order; if #9547 follows #6044, declare that dependency and ensure the test uses the final registration convention. I’m requesting changes for that missing order record only. Eligibility, conventions, intake and labels pass; relinker CI is still running, and platform product jobs are skipped. I ran the focused mode test in a temporary Git fixture, not the full project build.

@MarcZX10

Copy link
Copy Markdown
Contributor

CI update: the relinker run 39705282984 has now completed successfully on Ubuntu, Windows, macOS arm64 and macOS x86_64, including the ASAN coverage job. The platform product-build jobs were skipped by the repository workflow. My requested author coordination and Depends on record for the overlapping #6044 CMake registration remain unresolved, so the review state is unchanged.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1835 CMakeLists.txt
PR 7642 CMakeLists.txt
PR 9508 CMakeLists.txt
PR 10193 CMakeLists.txt
PR 10897 CMakeLists.txt
PR 13589 CMakeLists.txt
PR 13928 CMakeLists.txt
PR 13929 CMakeLists.txt
PR 16391 CMakeLists.txt
PR 16538 CMakeLists.txt
PR 21420 CMakeLists.txt
PR 21939 CMakeLists.txt
PR 22004 CMakeLists.txt
PR 22466 CMakeLists.txt
PR 22594 CMakeLists.txt
PR 23970 CMakeLists.txt

@github-actions github-actions Bot added fix error Closes an issue (Fixes #N) build labels Oct 22, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor

I reran the mode regression locally from the PR snapshot staged into an isolated Git index: test_tool_script_modes.py passes 1/1, the script-registration suite passes 40/40, and all four changed executables return 0 for --help. Current-main diff-check and conventions pass; the merge with current main is clean. The remaining contribution-rule issue is still open: #6044 remains open and pairwise merge-tree reports the root CMakeLists.txt registration hunk as conflicting. Please agree the order with its author, record it, and list Depends on if this PR must follow #6044. Also this head is 1 ahead/119 behind current upstream/main 4777cac (merge base a6dcea9), so update and rerun checks on current main before merge. I did not run a full runtime build.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focused tests pass locally: the PR snapshot test passes 1/1, the script-registration unit suite passes 40/40, and all four scripts launch with --help; conventions and diff-check also pass. Two repository requirements remain: coordinate the conflicting root CMake registration hunk with open #6044 and record the order/Depends on if required; and update this branch to current upstream/main 4777cac (it is 1 ahead/119 behind, merge base a6dcea9), then rerun checks. Product builds were not run.

@adriadam10 adriadam10 self-assigned this Oct 22, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx
xXPBSXx force-pushed the fix/tools-shebang-executable branch from 8ee787d to 680c143 Compare October 23, 2026 01:01
@xXPBSXx

xXPBSXx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks, I updated the branch to current main (83462cc, head 680c143, one commit) and reran the checks: test_tool_script_modes.py passes, test_test_registration.py passes, check_test_registration.py --scripts accepts the registration (173 scripts), check_conventions.py passes.

On the order with #6044: #9547 stays Depends on: none. Measured today: git merge --no-commit --no-ff of the #6044 head (5fa62e5) into main reports 35 conflicting files and 10 conflict hunks in the root CMakeLists.txt; the same merge into the #9547 branch reports the same 35 files and the same 10 hunks, so this PR adds no hunk of its own. The reason is that #6044 turns every Python add_test(NAME ...) of that file into add_component_test(tools NAME ...), and this PR adds one plain add_test(NAME tool_script_modes ...) next to them. #6044 currently needs a rebase (6222 commits behind main, 500 files) and has open review requests (changes requested by @adriadam10 on 16.10., last author commit 14.10.).

Proposed order: this PR first. The new entry comes along as a plain add_test, so when #6044 is rebased onto it, tool_script_modes has to be converted to add_component_test(tools NAME tool_script_modes ...) together with the other tools entries. If #6044 lands first instead, I will rebase this PR the same day and register the test with add_component_test(tools NAME tool_script_modes ...).

@TaymKal, as the author of #6044: does this order work for you? If #9547 is merged before your rebase, please include tool_script_modes in the conversion. I am adding this order to the PR description too.

AI-assisted (Claude Code).

@THEMANnt THEMANnt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 680c14387173 against author merge base 83462cc57dde. No actionable findings in this focused review.

Source review: The four shebang scripts change only their tracked modes from 100644 to 100755; Git confirms unchanged script blobs. The new test checks index modes rather than Windows filesystem permissions, and its CMake registration preserves a 20-second timeout. Python-interpreter invocation remains unchanged.

Validation: Windows x64 / CPython 3.11: the mode test passes without skips. Grafting it onto the baseline index fails one assertion listing precisely the four non-executable scripts. All four Python --help smoke checks return zero. Conventions, whitespace and script registration pass. Effective hosted relinker matrix/ASan and conventions jobs succeed; product jobs are skipped.

Scope: Local evidence establishes tracked modes, unchanged contents and CLI compatibility. Direct POSIX shebang execution was not independently run locally; no full application build is claimed.

@xXPBSXx

xXPBSXx commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Both points of the review of 22 October are resolved:

  1. Order with test: organize library tests and label CTest suites #6044: that pull request was closed on 24 October without being merged, so there is no longer a competing edit of the registration lines in the root CMakeLists.txt. main still registers its tests with plain add_test, as this branch does, so Depends on: none stays correct.
  2. Branch update: the head 680c143871 was rebased on main on 23 October (one commit). main has moved on since; at 3a2c51afd2, when I measured, git merge-tree of main and this head reported no conflict. Against the current main d2b3ee3bcc it is still clean.

Run on that merge result, on Windows 10 with Python 3.12.10: test_tool_script_modes.py passes (1 test); test_test_registration.py runs 49 tests with 1 skipped (test_ninja_output_encoding_with_a_cp1252_default, "requires a local Ninja to exercise its real output encoding") and passes; tools/check_test_registration.py --scripts accepts all 183 test scripts; tools/check_conventions.py --base upstream/main passes; the four scripts have mode 100755.

Not run: a product build (the change and its test touch only Python scripts and file modes), and nothing was rerun on Linux or macOS on this merge result. The head has an approving review since 24 October. Could you re-review the current head? I can rebase onto main again if you prefer that to the clean merge.

AI-assisted (Claude Code).

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test fails once this branch is merged with current main.

Head 680c143871 merged (--no-commit) onto main abed035468, clean merge. python3 -I tools/tests/test_tool_script_modes.py (Apple M2 Max, macOS 27.2, /usr/bin/python3 3.9.6):

AssertionError: Lists differ: ['tools/annotate_module.py has a shebang but mode 100644'] != []

tools/annotate_module.py arrived on main after this branch's base (added in 72f397a374, last touched in d1ac8d9117). It starts with #!/usr/bin/env python3 and is tracked as 100644, so it needs the same 100755 mode as the other four. The green CI run on this PR predates it, so main would go red on tool_script_modes after the merge.

With annotate_module.py also staged as 100755 (git update-index --chmod=+x), the test passes on the merged tree.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

xXPBSXx and others added 3 commits October 27, 2026 04:18
tools/annotate_module.py starts with a shebang and was added to main
after this branch was cut, so tool_script_modes fails on the merged
tree with "tools/annotate_module.py has a shebang but mode 100644".
Staging it as 100755 like the four scripts of the first commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

As jotitadev reported, the new tool_script_modes test failed once this branch was merged with main: tools/annotate_module.py starts with a shebang and was added to main as 100644 after this branch was cut. The new commit b32349f6d6b6cfe0864ced3598d486f837b71a83 sets it to 100755 like the other four scripts, and main (09f9a63f6b) is merged into the branch, head c3db7f2e929c0f2ba19f2c7d5c7b97e20cda487e. On Windows 10 I ran only the Python test: on the merge with main abed035468 it failed with exactly that message before the new commit and passes after it, and it passes on the head; the macOS run is jotitadev's, and the diff against main is now 7 files, +35. Could you re-review that exact head?

AI-assisted (Claude Code).

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked head c3db7f2e92 as asked: fixed.

Apple M2 Max, macOS 27.2, /usr/bin/python3 3.9.6. Head merged (--no-commit, clean) onto current main 2812b2987b, which is 274 commits past the 09f9a63f6b you merged.

  • python3 -I tools/tests/test_tool_script_modes.py: OK. No other shebang script under tools/ is tracked as 100644 on the merged tree.
  • Red control: with tools/annotate_module.py staged back to 100644, the test fails with the same message as before (tools/annotate_module.py has a shebang but mode 100644).
  • Relinker-only Release build, arm64, full suite: 357/357, including tool_script_modes (main alone: 356/356).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@THEMANnt THEMANnt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed c3db7f2e929c0f2ba19f2c7d5c7b97e20cda487e against 09f9a63f6b85aec9f36ce5d0d46f41c37cbd86fd.

Re-reviewed the updated executable-mode change. All five changed tool scripts now have tracked mode 100755; each script blob is identical to its author-base blob. The regression reads Git index modes, so Windows filesystem permission emulation does not weaken this check. The CMake entry retains a 20-second timeout. No actionable finding.

Windows/Python 3.11: the mode regression passes without skips, and all five scripts' Python --help invocations exit 0. Independently checked the mode/blob pairs with git ls-tree. This verifies tracked executable flags and interpreter invocation; direct POSIX shebang execution was not independently rerun locally.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed exact head c3db7f2e929c0f2ba19f2c7d5c7b97e20cda487e against current main aaccd0ba39. The merge preview is clean; its effective change against current main is limited to the five executable mode bits, the tool_script_modes test, and its CMake registration. The test checks Git-index modes for tracked Python tools with shebangs, which avoids relying on Windows permission emulation. The author and other reviewers report the focused regression passing on Windows and macOS, including a negative control for annotate_module.py; the hosted relinker jobs pass on this head. I did not run the Python test locally. No product build is applicable to this mode-and-test change.

@xXPBSXx

xXPBSXx commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the hint. tools/annotate_module.py was already set to 100755 on this branch (commit b32349f6d6b6, 27 October); tools/export_gap.py, which main gained afterwards, was the one missing, as ycbuzi reported on 11 November. I merged main aa698cdc0843 into the branch and added one commit, 71dec9824466, that sets tools/export_gap.py to 100755 (git update-index --chmod=+x, no content change). All six scripts with a shebang on main (annotate_module.py, check_compile.py, export_gap.py, nid_names.py, stubgen.py, unwrap_self.py) are now 100755 on the head.

Before the new commit, on the merge with main, python tools/tests/test_tool_script_modes.py failed with tools/export_gap.py has a shebang but mode 100644; after it, the test passes (1 test) and python tools/check_conventions.py reports no findings. I ran only these two Python checks, on Windows 10; I did not run a build or the full relinker suite.

#21454, opened on 16 November, sets the same six modes; whichever of the two is merged first leaves the other with nothing to change.

Could you re-review the new head?

AI-assisted (Claude Code).

This was referenced Nov 21, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the change makes the shebang tools executable and adds a test that guards their tracked modes.

What I ran

Reviewed head 71dec9824466ec464b1894c146accd7e114b53ab and the prepared diff. No commands or tests were run.

Results

Check Result Note
Diff and changed code passed Mode changes and test registration reviewed
Tests not run Only author-reported results are available

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests were run. Author-reported Windows and WSL2 results were not independently verified. The full text of these changed files was not read because their changes only alter file modes: tools/annotate_module.py, tools/check_compile.py, tools/export_gap.py, tools/nid_names.py, tools/stubgen.py, and tools/unwrap_self.py. All changed files are listed as included in the manifest; no exclusions were listed.

To get this to a good state

Nothing is required.

@oneandonlydean
oneandonlydean merged commit 58db39b into boykopovar:main Nov 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build fix error Closes an issue (Fixes #N)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools: four scripts start with a shebang but are not executable

10 participants