René's URL Explorer Experiment


Title: run_commit_hook picks the WSL launcher stub on Windows: bare bash.exe resolves from System32 before PATH · Issue #2198 · gitpython-developers/GitPython · GitHub

Open Graph Title: run_commit_hook picks the WSL launcher stub on Windows: bare bash.exe resolves from System32 before PATH · Issue #2198 · gitpython-developers/GitPython

X Title: run_commit_hook picks the WSL launcher stub on Windows: bare bash.exe resolves from System32 before PATH · Issue #2198 · gitpython-developers/GitPython

Description: Summary On Windows, run_commit_hook spawns extensionless hooks as a bare "bash.exe" and leaves the executable lookup to Windows. CreateProcess resolves a bare name in this order: application dir -> parent cwd -> System32 -> Windows dir -...

Open Graph Description: Summary On Windows, run_commit_hook spawns extensionless hooks as a bare "bash.exe" and leaves the executable lookup to Windows. CreateProcess resolves a bare name in this order: application dir ->...

X Description: Summary On Windows, run_commit_hook spawns extensionless hooks as a bare "bash.exe" and leaves the executable lookup to Windows. CreateProcess resolves a bare name in this order: applicat...

Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2198

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"run_commit_hook picks the WSL launcher stub on Windows: bare bash.exe resolves from System32 before PATH","articleBody":"### Summary\n\nOn Windows, `run_commit_hook` spawns extensionless hooks as a **bare** `\"bash.exe\"` and leaves the executable lookup to Windows. `CreateProcess` resolves a bare name in this order:\n\n```\napplication dir  ->  parent cwd  ->  System32  ->  Windows dir  ->  PATH\n```\n\nso `C:\\Windows\\System32\\bash.exe` — the **WSL launcher stub**, present on any machine where the \"Windows Subsystem for Linux\" optional feature has been enabled — is found at **step 3, before PATH is ever consulted**.\n\nIf no WSL distro is installed, that stub prints and exits 1:\n\n```\nWindows Subsystem for Linux has no installed distributions.\nYou can resolve this by installing a distribution with the instructions below:\n\nUse 'wsl.exe --list --online' to list available distributions\nand 'wsl.exe --install \u003cDistro>' to install.\n```\n\nGitPython surfaces this as `HookExecutionError`, so **every** `repo.index.commit()` fails on such a machine and the hook body never runs — regardless of what the hook contains.\n\n### Version\n\n- GitPython 3.1.46 (reproduced), and current `main` still builds `cmd = [\"bash.exe\", ...]`\n- Windows 11, Git for Windows 2.x, WSL optional feature enabled with **no** distro installed\n\n### Reproduction\n\n```python\nfrom pathlib import Path\nimport git\n\nrepo = git.Repo.init(\"scratch\")\nhook = Path(\"scratch/.git/hooks/pre-commit\")\nhook.write_text(\"#!/bin/sh\\necho HOOK RAN\\nexit 0\\n\", newline=\"\\n\")\nhook.chmod(0o755)\n\nPath(\"scratch/f.txt\").write_text(\"x\\n\")\nrepo.index.add([\"f.txt\"])\nrepo.index.commit(\"test\")   # HookExecutionError on a machine with the WSL stub\n```\n\n`git commit` from Git Bash on the same repo runs the hook fine, which makes this look like a hook or repo problem rather than a library one.\n\n### Why the usual workarounds don't apply\n\n| Workaround | Why it cannot help |\n|---|---|\n| Put `C:\\Program Files\\Git\\bin` on PATH | PATH is consulted only *after* System32 |\n| Give the hook an absolute-path shebang | `run_commit_hook` never reads the shebang |\n| Reorder PATH ahead of System32 | Irrelevant — System32 is searched before PATH regardless of PATH contents |\n\nThe only thing that changes the outcome is naming the interpreter by absolute path.\n\n### Note on the current comment in the source\n\nThe relative-path calculation carries this comment:\n\n> Different drives have no relative path on Windows. Git Bash accepts an absolute path in this form, although a relative path is preferable because it also works with the Windows Subsystem for Linux wrapper.\n\nThat reads as though WSL bash is an acceptable target. When WSL is a stub with no distro it is not merely acceptable-but-different, it is guaranteed to fail — and because of the `CreateProcess` search order it is the one that gets selected by default, ahead of Git's own bash.\n\n### Suggested fix\n\nResolve Git for Windows' `bash.exe` by absolute path and use it explicitly, rejecting any candidate under `%SystemRoot%`. Candidate order that works well in practice:\n\n1. the `bin/` directory beside the `git.exe` already on PATH (`shutil.which(\"git\")` → `../bin/bash.exe`)\n2. `GIT_INSTALL_ROOT`\n3. standard install locations (`C:\\Program Files\\Git`, `C:\\Program Files (x86)\\Git`)\n\nFalling back to today's bare `\"bash.exe\"` when none is found would keep behavior unchanged for anyone currently relying on WSL bash.\n\nI am working around it downstream by patching the single `safer_popen` call site in `git/index/fun.py` to rewrite a bare `bash.exe` / `sh.exe` argv[0] to Git's absolute bash. Happy to open a PR against `run_commit_hook` if the approach above looks acceptable.\n\n### Possibly related\n\n- #1999 (closed, not planned) — a different failure in the same Windows hook path\n- #971 / #1129 — the `WinError 193` reports that motivated b719e18, the commit that introduced the `bash.exe` spawn\n","author":{"url":"https://github.com/piyushmakhija28","@type":"Person","name":"piyushmakhija28"},"datePublished":"2026-07-30T09:54:36Z","url":"https://github.com/gitpython-developers/GitPython/issues/2198"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cef1e2ee-877b-67f6-7bcb-bce0cbb5855e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAC5A:1EC9BC:C83D39:10049B6:6B0100BA
html-safe-nonce35a9d672ad1cb19c61caa8cf9234412e2c0c83ba2f5235a87b88e50bf3850266
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzVBOjFFQzlCQzpDODNEMzk6MTAwNDlCNjo2QjAxMDBCQSIsInZpc2l0b3JfaWQiOiIzODYxMDQ4NzQwNDUwMjA1ODgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaccef8ffabf4e691a3738bd8970f084d96f91931d0aa4a3f1ad4a3f50dcddb5b5e
hovercard-subject-tagissue:5018487192
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/2198/issue_layout
twitter:imagehttps://opengraph.githubassets.com/73e93809b0b682d6ae04f2c4ebf84e6af7c7134c8e03721331fefe27c204821d/gitpython-developers/GitPython/issues/2198
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/73e93809b0b682d6ae04f2c4ebf84e6af7c7134c8e03721331fefe27c204821d/gitpython-developers/GitPython/issues/2198
og:image:altSummary On Windows, run_commit_hook spawns extensionless hooks as a bare "bash.exe" and leaves the executable lookup to Windows. CreateProcess resolves a bare name in this order: application dir ->...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepiyushmakhija28
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/issues/2198#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F2198
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F2198
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2198
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2198
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2198
gitpython-developershttps://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Codehttps://github.com/gitpython-developers/GitPython
Issues1 (1)https://github.com/gitpython-developers/GitPython/issues
Pull requestshttps://github.com/gitpython-developers/GitPython/pulls
Discussionshttps://github.com/gitpython-developers/GitPython/discussions
Actionshttps://github.com/gitpython-developers/GitPython/actions
Security and quality42 (42)https://github.com/gitpython-developers/GitPython/security
Insightshttps://github.com/gitpython-developers/GitPython/insights
https://github.com/gitpython-developers/GitPython
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2198
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2198
#2199https://github.com/gitpython-developers/GitPython/pull/2199
run_commit_hook picks the WSL launcher stub on Windows: bare bash.exe resolves from System32 before PATHhttps://github.com/gitpython-developers/GitPython/issues/2198#top
#2199https://github.com/gitpython-developers/GitPython/pull/2199
https://github.com/piyushmakhija28
piyushmakhija28https://github.com/piyushmakhija28
on Jul 30, 2026https://github.com/gitpython-developers/GitPython/issues/2198#issue-5018487192
[Windows] Hooks for submodules that are configured outside the submodule repository lead to error in PurePath.relative_to #1999https://github.com/gitpython-developers/GitPython/issues/1999
OSError: [WinError 193] %1 is not a valid Win32 application when commiting LFS-enabled repository on Windows #971https://github.com/gitpython-developers/GitPython/issues/971
Issue while trying to commit - "repo.index.commit" #1129https://github.com/gitpython-developers/GitPython/issues/1129
b719e18https://github.com/gitpython-developers/GitPython/commit/b719e1809c2c81283e930086faebd7d6050cd5d7
Byronhttps://github.com/Byron
on Jul 30, 2026https://github.com/gitpython-developers/GitPython/issues/2198#event-28717047560
Resolve Windows hook Bash through PATH (#2198)https://github.com/gitpython-developers/GitPython/commit/7131bcc27f2d96851eb6d667dc1207ab6ece5c61
#2198https://github.com/gitpython-developers/GitPython/issues/2198
7131bcchttps://github.com/gitpython-developers/GitPython/commit/7131bcc27f2d96851eb6d667dc1207ab6ece5c61
Byronhttps://github.com/Byron
completedhttps://github.com/gitpython-developers/GitPython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2199https://github.com/gitpython-developers/GitPython/pull/2199
on Jul 30, 2026https://github.com/gitpython-developers/GitPython/issues/2198#event-28717584011
Sign up for freehttps://github.com/signup?return_to=https://github.com/gitpython-developers/GitPython/issues/2198
Sign in to commenthttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2198
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.