Skip to content

Commit d99a603

Browse files
committed
fix: use shell=True on Windows for npx.cmd compatibility
Windows requires shell=True to properly execute .cmd files like npx.cmd. This should resolve the hanging issue on Windows Python 3.9. Fixes #4 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5319faa commit d99a603

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/promptfoo/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
import os
9+
import platform
910
import shutil
1011
import subprocess
1112
import sys
@@ -57,18 +58,25 @@ def main() -> NoReturn:
5758
# Use the full path to npx for Windows compatibility
5859
cmd = [npx_path, "--yes", "promptfoo@latest"] + sys.argv[1:]
5960

61+
# On Windows, use shell=True to properly handle .cmd files
62+
is_windows = platform.system() == "Windows"
63+
6064
try:
61-
# Execute the command and inherit stdio
65+
# Execute the command and pass through stdio
6266
result = subprocess.run(
6367
cmd,
6468
env=os.environ.copy(),
6569
check=False, # Don't raise exception on non-zero exit
70+
shell=is_windows, # Use shell on Windows for .cmd compatibility
6671
)
6772
sys.exit(result.returncode)
6873
except KeyboardInterrupt:
6974
# Handle Ctrl+C gracefully
7075
print("\nInterrupted by user", file=sys.stderr)
7176
sys.exit(130)
77+
except subprocess.TimeoutExpired:
78+
print("ERROR: Command timed out after waiting too long", file=sys.stderr)
79+
sys.exit(1)
7280
except Exception as e:
7381
print(f"ERROR: Failed to execute promptfoo: {e}", file=sys.stderr)
7482
sys.exit(1)

0 commit comments

Comments
 (0)