Skip to content

Commit 5ddb551

Browse files
committed
fix: add stdin=DEVNULL and use -y flag to prevent npx hanging
The issue was that npx was waiting for user input on the prompt 'Ok to proceed? (y)' even with the --yes flag. Changes: - Use -y instead of --yes (more widely supported short form) - Set stdin=subprocess.DEVNULL to prevent any prompts from blocking - This ensures npx won't wait for user input in CI environments Tested locally and the command completes immediately without hanging.
1 parent 6f3a523 commit 5ddb551

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/promptfoo/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ def main() -> NoReturn:
5757

5858
# Build the command: npx promptfoo@latest <args>
5959
# Use the full path to npx and keep shell=False for security and reliability
60-
cmd = [npx_path, "--yes", "promptfoo@latest"] + sys.argv[1:]
60+
# Use -y (short form) which is more widely supported than --yes
61+
cmd = [npx_path, "-y", "promptfoo@latest"] + sys.argv[1:]
6162

6263
try:
6364
# Execute the command and inherit stdio
65+
# stdin=DEVNULL prevents npx from blocking on prompts like "Ok to proceed? (y)"
6466
result = subprocess.run(
6567
cmd,
6668
env=os.environ.copy(),
69+
stdin=subprocess.DEVNULL, # Prevent prompts from blocking
6770
check=False, # Don't raise exception on non-zero exit
6871
shell=False, # Keep shell=False for security - works on all platforms with full path
6972
)

0 commit comments

Comments
 (0)