Skip to content
Latchkey

poetry run: Run in the Project Env Command Reference

Run tools inside the project venv without activating a shell.

poetry run executes a command with the project virtual environment active for that one invocation. CI uses it to run pytest, linters, and scripts without an activation step.

Common flags / usage

  • poetry run pytest -- run tests in the project env
  • poetry run python -m mypackage -- run a module
  • poetry run ruff check . -- run a linter installed in the env
  • poetry run python -c "..." -- run an inline snippet

Example

shell
- run: poetry install --no-interaction
- run: poetry run pytest -q
- run: poetry run ruff check .

In CI

poetry run needs an environment, so poetry install must run first or the command fails. Using poetry run avoids the cross-step activation problem -- each invocation gets the right interpreter and packages on PATH.

Key takeaways

  • poetry run executes a command inside the project env for one invocation.
  • Run poetry install before poetry run, or the env will not exist.
  • It sidesteps the cross-step venv activation problem in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →