fix(tools): suppress Windows AutoRun stderr in shell commands#1556
Conversation
On Windows, subprocess.Popen with shell=True invokes cmd.exe which runs AutoRun scripts from the registry. If AutoRun references a nonexistent path, stderr gets "The system cannot find the path specified." even when the command succeeds. This switches to an explicit cmd /D /S /C invocation to disable AutoRun processing, preventing spurious stderr output. Fixes agentscope-ai#1545 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue on Windows where Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves an issue with spurious stderr output on Windows during shell command execution by disabling AutoRun scripts. The approach of explicitly calling cmd.exe with the /D flag is a clean and targeted fix. The change is correctly scoped to Windows environments. I have one suggestion to improve the accuracy of a code comment for better long-term maintainability.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Welcome to CoPaw! 🎉Thank you @mvanhorn for your first contribution! Your PR has been merged. 🚀 We'd love to give you a shout-out in our release notes! If you're comfortable sharing, please reply to this comment with your social media handles using the format below:
Thanks again for helping make CoPaw better! |
Summary
On Windows, every
execute_shell_commandcall produces spurious "The system cannot find the path specified." stderr output, even when the command succeeds with returncode 0. This happens becausesubprocess.Popen(shell=True)invokescmd.exe, which runs AutoRun scripts from the registry (HKCU\Software\Microsoft\Command Processor\AutoRun). If AutoRun references a nonexistent path, stderr gets polluted.Changes
shell.py: Replaceshell=Truewith an explicit["cmd", "/D", "/S", "/C", cmd]invocation. The/Dflag disables AutoRun processing (Microsoft docs). The/Sflag ensures the inner command string is passed through unchanged, preserving pipes, redirects, and shell builtins.This function is only called on Windows (
sys.platform == "win32"gate at line 166), so non-Windows platforms are unaffected.Testing
The fix follows standard Windows practice for subprocess invocation. The existing
creationflags=subprocess.CREATE_NEW_PROCESS_GROUPhandling is preserved. Commands with pipes (echo a | sort), redirects (echo a > file), and shell builtins (dir,type) continue to work becausecmd /S /Cprocesses them.Fixes #1545
This contribution was developed with AI assistance (Claude Code).