Skip to content

Commit 0d7d8f0

Browse files
mldangelorenovate[bot]claude
authored
fix: implement PROMPTFOO_VERSION, KeyboardInterrupt handling, nvm version (#27)
* chore(deps): lock file maintenance (#16) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): lock file maintenance (#17) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): lock file maintenance (#21) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael <michael.l.dangelo@gmail.com> * chore(deps): lock file maintenance (#23) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael <michael.l.dangelo@gmail.com> * chore(deps): lock file maintenance (#24) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael <michael.l.dangelo@gmail.com> * fix: implement PROMPTFOO_VERSION, add KeyboardInterrupt handling, update nvm version - Implement PROMPTFOO_VERSION env var to allow pinning the npx version (was documented in README but never actually implemented) - Add KeyboardInterrupt handling so Ctrl+C exits cleanly with code 130 instead of printing a Python traceback - Update nvm install script references from v0.39.0 to v0.40.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: increase test job timeout from 15 to 30 minutes Windows smoke tests hit the 15-minute limit due to npm install + npx download time. 30 minutes gives enough headroom. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5db1270 commit 0d7d8f0

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
test:
7373
name: Test (py${{ matrix.python-version }}, ${{ matrix.os }})
7474
runs-on: ${{ matrix.os }}
75-
timeout-minutes: 15
75+
timeout-minutes: 30
7676
strategy:
7777
matrix:
7878
# Temporarily excluding macos-latest due to GitHub Actions runner resource constraints
@@ -152,7 +152,7 @@ jobs:
152152
test-npx-fallback:
153153
name: Test npx fallback (py${{ matrix.python-version }}, ${{ matrix.os }})
154154
runs-on: ${{ matrix.os }}
155-
timeout-minutes: 15
155+
timeout-minutes: 30
156156
strategy:
157157
matrix:
158158
# Test npx fallback (without global install)

src/promptfoo/cli.py

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
_WRAPPER_ENV = "PROMPTFOO_PY_WRAPPER"
1717
_WINDOWS_SHELL_EXTENSIONS = (".bat", ".cmd")
18+
_VERSION_ENV = "PROMPTFOO_VERSION"
1819

1920

2021
def check_node_installed() -> bool:
@@ -178,33 +179,37 @@ def main() -> NoReturn:
178179
179180
Executes promptfoo using subprocess.run() with minimal configuration.
180181
"""
181-
# Check for Node.js installation
182-
if not check_node_installed():
183-
print_installation_help()
184-
sys.exit(1)
185-
186-
# Build command: try external promptfoo first, fall back to npx
187-
promptfoo_path = None if os.environ.get(_WRAPPER_ENV) else _find_external_promptfoo()
188-
if promptfoo_path:
189-
record_wrapper_used("global")
190-
cmd = [promptfoo_path] + sys.argv[1:]
191-
env = os.environ.copy()
192-
env[_WRAPPER_ENV] = "1"
193-
result = _run_command(cmd, env=env)
194-
else:
195-
npx_path = shutil.which("npx")
196-
if npx_path:
197-
record_wrapper_used("npx")
198-
cmd = [npx_path, "-y", "promptfoo@latest"] + sys.argv[1:]
199-
result = _run_command(cmd)
200-
else:
201-
record_wrapper_used("error")
202-
print("ERROR: Neither promptfoo nor npx is available.", file=sys.stderr)
203-
print("Please install promptfoo: npm install -g promptfoo", file=sys.stderr)
204-
print("Or ensure Node.js is properly installed.", file=sys.stderr)
182+
try:
183+
# Check for Node.js installation
184+
if not check_node_installed():
185+
print_installation_help()
205186
sys.exit(1)
206187

207-
sys.exit(result.returncode)
188+
# Build command: try external promptfoo first, fall back to npx
189+
promptfoo_path = None if os.environ.get(_WRAPPER_ENV) else _find_external_promptfoo()
190+
if promptfoo_path:
191+
record_wrapper_used("global")
192+
cmd = [promptfoo_path] + sys.argv[1:]
193+
env = os.environ.copy()
194+
env[_WRAPPER_ENV] = "1"
195+
result = _run_command(cmd, env=env)
196+
else:
197+
npx_path = shutil.which("npx")
198+
if npx_path:
199+
record_wrapper_used("npx")
200+
version = os.environ.get(_VERSION_ENV, "latest")
201+
cmd = [npx_path, "-y", f"promptfoo@{version}"] + sys.argv[1:]
202+
result = _run_command(cmd)
203+
else:
204+
record_wrapper_used("error")
205+
print("ERROR: Neither promptfoo nor npx is available.", file=sys.stderr)
206+
print("Please install promptfoo: npm install -g promptfoo", file=sys.stderr)
207+
print("Or ensure Node.js is properly installed.", file=sys.stderr)
208+
sys.exit(1)
209+
210+
sys.exit(result.returncode)
211+
except KeyboardInterrupt:
212+
sys.exit(130)
208213

209214

210215
if __name__ == "__main__":

src/promptfoo/instructions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _get_wsl_instructions() -> list[str]:
198198
"Recommended approach:",
199199
" 1. Use your Linux distribution's package manager (see below)",
200200
" 2. Or use nvm for version management:",
201-
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash",
201+
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
202202
" source ~/.bashrc",
203203
" nvm install 20",
204204
"",
@@ -255,7 +255,7 @@ def _get_debian_instructions(env: Environment) -> list[str]:
255255
lines.extend(
256256
[
257257
"You don't have sudo access. Use nvm (Node Version Manager):",
258-
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash",
258+
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
259259
" source ~/.bashrc",
260260
" nvm install 20",
261261
]
@@ -290,7 +290,7 @@ def _get_rhel_instructions(env: Environment) -> list[str]:
290290
lines.extend(
291291
[
292292
"Use nvm (Node Version Manager) - no sudo needed:",
293-
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash",
293+
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
294294
" source ~/.bashrc",
295295
" nvm install 20",
296296
]
@@ -315,7 +315,7 @@ def _get_rhel_instructions(env: Environment) -> list[str]:
315315
lines.extend(
316316
[
317317
"Use nvm (Node Version Manager) - no sudo needed:",
318-
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash",
318+
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
319319
" source ~/.bashrc",
320320
" nvm install 20",
321321
]
@@ -362,7 +362,7 @@ def _get_generic_linux_instructions() -> list[str]:
362362
"Use your package manager to install Node.js, or use nvm:",
363363
"",
364364
"Option 1 - nvm (Node Version Manager, works on any Linux):",
365-
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash",
365+
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
366366
" source ~/.bashrc",
367367
" nvm install 20",
368368
"",
@@ -379,7 +379,7 @@ def _get_macos_instructions() -> list[str]:
379379
" brew install node",
380380
"",
381381
"Option 2 - nvm (Node Version Manager, for version management):",
382-
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash",
382+
" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
383383
" source ~/.zshrc # or ~/.bashrc",
384384
" nvm install 20",
385385
"",

0 commit comments

Comments
 (0)