Skip to content

fix(venv): bulletproof virtual env handling#3437

Merged
mkoura merged 1 commit intomasterfrom
bulletproof_venv_handling
Apr 28, 2026
Merged

fix(venv): bulletproof virtual env handling#3437
mkoura merged 1 commit intomasterfrom
bulletproof_venv_handling

Conversation

@mkoura
Copy link
Copy Markdown
Collaborator

@mkoura mkoura commented Apr 28, 2026

Detect activated/missing/wrong virtual envs across the Make targets and shell scripts, with shared helpers and consistent error messages.

@mkoura mkoura requested a review from saratomaz as a code owner April 28, 2026 10:27
@mkoura mkoura requested review from Copilot and removed request for saratomaz April 28, 2026 10:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens developer/CI workflows by standardizing how scripts and Make targets detect and enforce the expected Python virtual environment (.venv), aiming to prevent running commands in the wrong (or missing) venv and to provide consistent error messages.

Changes:

  • Introduces shared venv helpers (is_venv_active, assert_correct_venv) and adopts them across multiple scripts.
  • Adds Makefile guard targets to check for venv existence/activation and wires them into common targets; improves clean-all safety around active venv removal.
  • Adds venv “must be inactive” checks to runner scripts and makes minor shell-robustness tweaks (${VAR:-} patterns, awk regex).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/setup_test_env.sh Small parameter expansion tweaks for set -u friendliness.
scripts/setup_dev_venv.sh Tightens repo-root check and uses shared venv helpers for consistent behavior.
scripts/reinstall_editable.sh Replaces inline venv checks with shared helper and asserts correct venv.
scripts/deploy_doc.sh Uses shared venv assertion and introduces TOP_DIR resolution.
scripts/common.sh Adds shared venv detection/assertion helpers with canonical-path comparison.
runner/regression.sh Refuses to run when any venv is active (uses shared helper).
runner/node_upgrade.sh Refuses to run when any venv is active (uses shared helper).
Makefile Adds venv guard targets, updates target prerequisites, safer clean-all, and awk regex tweak.
.source.dev Validates activated venv is the repo’s .venv using canonicalized path comparison.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile Outdated
Comment thread .source.dev
Comment thread scripts/deploy_doc.sh
@mkoura mkoura force-pushed the bulletproof_venv_handling branch 2 times, most recently from b675bab to e884753 Compare April 28, 2026 12:21
@mkoura mkoura requested a review from Copilot April 28, 2026 12:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile Outdated
Comment thread .source.dev
@mkoura mkoura force-pushed the bulletproof_venv_handling branch 2 times, most recently from 8dc59e4 to e11c104 Compare April 28, 2026 13:17
@mkoura mkoura requested a review from Copilot April 28, 2026 13:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .source.dev
Comment thread Makefile Outdated
Comment thread Makefile Outdated
@mkoura mkoura force-pushed the bulletproof_venv_handling branch from e11c104 to 8e0ef2b Compare April 28, 2026 14:58
Detect activated/missing/wrong virtual envs across the Make targets
and shell scripts, with shared helpers and consistent error messages.

- Makefile: add .check-venv-exists and .check-venv-activated guard
  targets, wire them into cluster-scripts, start/stop-cluster,
  init-lint, lint, fmt, build-doc. cluster-scripts now relies on the
  activated venv's PATH instead of hardcoded $(VENV)/bin/. clean-all
  no longer takes 'clean' as prereq so the venv check runs first; it
  refuses to wipe the currently-activated venv (canonical-path
  compare). Help-target awk regex switched from .*? to .* for POSIX
  awk compatibility. .check-venv-activated overrides SHELL via
  'command -v bash' so it can source the bash-only
  scripts/common.sh on systems without /bin/bash (NixOS).
- scripts/common.sh: add is_venv_active and assert_correct_venv
  helpers (canonical-path compare, descriptive error messages).
- scripts/deploy_doc.sh, scripts/reinstall_editable.sh,
  scripts/setup_dev_venv.sh: replace duplicated inline checks with
  assert_correct_venv / is_venv_active.
- scripts/setup_dev_venv.sh: also tighten the repo-root sanity check
  (require cardano_node_tests/tests, not just cardano_node_tests) and
  reorganize the prompt/sync flow.
- runner/regression.sh, runner/node_upgrade.sh: refuse to run inside
  any active virtual env via is_venv_active.
- scripts/setup_test_env.sh: cosmetic ${VAR:-""} -> ${VAR:-}.
@mkoura mkoura force-pushed the bulletproof_venv_handling branch from 8e0ef2b to e89afa2 Compare April 28, 2026 15:00
@mkoura mkoura merged commit 0d43ee5 into master Apr 28, 2026
1 check passed
@mkoura mkoura deleted the bulletproof_venv_handling branch April 28, 2026 15:02
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