Skip to content

fix(tests): bash subprocess tests source ~/.bashrc under SSH and fail #2306

Closed

Description

@JarryShaw

Describe the bug
Tests that run subprocess.run(['bash', '-e', '-c', …]) inherit SSH_CLIENT. Non-interactive bash sources ~/.bashrc when SSH_CLIENT is set or stdin is a socket, and SHLVL is below 2. Its output and PATH then leak into the step under test.

Reproduction
From an SSH session, SHLVL=0 python -m pytest tests/project/test_apt_packages_1967.py::TestTheFormerShellAgrees::test_seed tests/project/test_project_status.py::TestTheStepRunsTheFetchedScript::test_both_files_are_fetched_and_the_import_finds_the_helper gives SUBFAILED(job='engine-tests', restored=True) and pypcap-parity: (0, '~/.bashrc: line 14: autoload: command not found…') != (0, 'Seeded 3 .deb files\n', …). In the second, the bashrc's PATH puts the real gh before the stub: gh: Bad credentials (HTTP 401).

Expected behavior
Each step's shell runs as GitHub Actions runs it, bash --noprofile --norc. Measured: with --norc, SSH_CLIENT set and a socket stdin, no bashrc runs.

Additional context
Adding stdin=subprocess.DEVNULL is not enough: pytest already gives fd 0 /dev/null, and the failure above came from SSH_CLIENT. Fix every ['bash', …] call in tests/project/, ideally through one helper in tests/_support. CI does not set SSH_CLIENT, so this is local only.

Activity

  1. added this to the PyPCAPKit v1.5 milestone on Oct 26, 2026
  2. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    testPull requests that add or correct tests (test: subject prefix)
    on Oct 26, 2026
  3. moved this to Pending in PyPCAPKiton Oct 26, 2026
  4. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 26, 2026
  5. moved this from Pending to WIP in PyPCAPKiton Oct 26, 2026
  6. JarryShaw commented on Oct 26, 2026

    @JarryShaw
    OwnerAuthor

    Fixed on main in bb017ff (a test/docs-only push). The tests it touches pass on the pushed tree.

  7. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)testPull requests that add or correct tests (test: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions