fix: clear Windows error for bash/git tools - #116
Draft
aryansk wants to merge 1 commit into
Draft
Conversation
Fixes shauryagangrade#54 On native Windows, shell=True invokes cmd.exe, not bash, so bash syntax fails with confusing subprocess errors. Detect missing bash (shutil.which) and fail with actionable message pointing to docs/windows.md and WSL2/Git Bash, instead of running cmd.exe. Same for git when not on PATH. Validation: py_compile passes, git diff --check clean; Windows check returns clear message when os.name == nt and no bash/git, otherwise proceeds as before.
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.
Fixes #54
Problem
execute_bashrunssubprocess.run(command, shell=True, ...)and names itself "bash". On native Windows,shell=Trueinvokescmd.exe, so bash syntax fails, andgit_*tools assume a POSIX-ish git. GCode currently has no Windows path despite the pure-Python grep fallback added in 0.2.0. Running on native Windows fails with confusing subprocess errors rather than a clear actionable message.Change
gcode/tools.py:execute_bash— onos.name == "nt"checkshutil.which("bash"); if missing, returnexecute_bash: bash not found on native Windows. GCode's bash tool requires bash (use WSL2 or Git Bash). See docs/windows.md …instead of invokingcmd.exegcode/tools.py:_git— onos.name == "nt"checkshutil.which("git"); if missing, returngit not found on native Windows. Install Git for Windows … See docs/windows.mdWhy this approach
Minimal, platform-aware, and matches the acceptance criteria: "Running on Windows fails with a clear, actionable message rather than a confusing subprocess error — or works." WSL2/Git Bash already provide bash, so detecting
bashon PATH distinguishes the working Windows setups from nativecmd.exe. The existingdocs/windows.md(merged in #87) already documents WSL2/Git Bash, so the error points there.Testing
Documentation and release impact
Review notes