You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(tests): bash subprocess tests source ~/.bashrc under SSH and fail #2306
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
test: run bash subprocess tests with --noprofile --norc (#2306)
JarryShaw commentedon Oct 26, 2026
Fixed on
mainin bb017ff (a test/docs-only push). The tests it touches pass on the pushed tree.test(project): render bash argv findings with ast.get_source_segment (#…