Skip to content

Fix robot command not found when installed via uv tool#718

Merged
oboehmer merged 4 commits intomainfrom
ds-pabot-robot-call
Mar 26, 2026
Merged

Fix robot command not found when installed via uv tool#718
oboehmer merged 4 commits intomainfrom
ds-pabot-robot-call

Conversation

@danischm
Copy link
Member

Summary

  • Use sys.executable -m robot instead of bare robot for pabot subprocess invocation
  • Fixes "robot: command not found" when nac-test is installed in an isolated environment (e.g. uv tool install)

Root cause

Pabot spawns robot as a subprocess by name. When nac-test is installed via uv tool install, the robot binary lives inside the isolated venv and is not on the system PATH.

Fix

Pass --command <python> -m robot --end-command to pabot so it invokes robot through the current Python interpreter, which always resolves to the correct venv.

@danischm danischm requested a review from oboehmer March 26, 2026 09:06
Copy link
Collaborator

@oboehmer oboehmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved.. we need to see how we can properly test the uv tool .. installation method, this is clearly a test escape. I am building a v2.0.0b2 with this fix for now

@oboehmer oboehmer dismissed a stale review March 26, 2026 12:09

working on this myself

Copy link
Collaborator

@oboehmer oboehmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will push a different fix as discussed.. also raise an issue to properly test this in the pipeline

…ecutable

Use sysconfig.get_path("scripts") / "robot" to locate the robot binary,
consistent with the existing pyats subprocess runner pattern. This also
adds an upfront existence check with a clear RuntimeError message rather
than failing deep inside pabot with a cryptic error.

Adds unit tests covering correct resolution, missing-binary error, and
verifying pabot is never invoked when the binary is absent.
@oboehmer oboehmer force-pushed the ds-pabot-robot-call branch from 60205f0 to 1b9ec32 Compare March 26, 2026 12:18
@oboehmer oboehmer merged commit 528dea3 into main Mar 26, 2026
22 checks passed
@oboehmer oboehmer deleted the ds-pabot-robot-call branch March 26, 2026 12:39
oboehmer added a commit that referenced this pull request Mar 26, 2026
…#611, #719)

Replace CliRunner with subprocess.run() in E2E tests, eliminating the
pabot writer singleton workaround and giving each scenario a fully
isolated process. A new test-e2e CI job installs nac-test via
`uv tool install` before running E2E tests, exercising the exact
entrypoint path that end-users get and catching regressions like #718
(robot not found in isolated venv).

- Remove _reset_pabot_writer() singleton hack from e2e/conftest.py
- Replace CliRunner.invoke() with subprocess.run(), passing env dict
  directly (no more class_mocker/monkeypatching)
- Remove class_mocker fixture (no longer needed anywhere)
- Update test_cli_has_no_exception to check stderr for tracebacks
  (module-level import errors bypass CLI exception handling and land
  in stderr — verified by injecting a fake import error)
- Add test-e2e CI job (full 4-Python matrix, Linux): installs via
  `uv tool install`, verifies `which nac-test` resolves to the uv
  tool bin dir, then runs pytest tests/e2e/ against that entrypoint
- Exclude tests/e2e from the existing test job (moved to test-e2e)
- Update notification job to include test-e2e in needs/success check
oboehmer added a commit that referenced this pull request Mar 26, 2026
…719)

Replace the separate `uv sync` + `uv run pytest` steps in the `test-e2e`
job with a single `uv tool install --with pytest --with pytest-xdist
--with pytest-httpserver --with flask` invocation. pytest now runs
directly inside the isolated tool environment alongside nac-test, with
no dev venv on PATH to shadow the tool env's robot binary.

This correctly reproduces the end-user scenario and ensures regressions
like #718 (pabot unable to locate robot in an isolated venv) are caught
by CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants