test_run_with_command_flags fails on macOS (BSD printenv doesn't support --version)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start with tests/test_cli.py::test_run_with_command_flags and inspect how it invokes dotenv run printenv --version. Replace the OS-specific sentinel with the suggested Python argv-echoing command, then run this test with pytest or tox on macOS and confirm the flag-forwarding assertion passes.
Written by the indexing model from the issue text.
Description
Description
tests/test_cli.py::test_run_with_command_flags fails when running the test suite (via tox or pytest) on macOS.
tests/test_cli.py::test_run_with_command_flags FAILED
AssertionError: Unexpected exit code 1 (expected 0)
stdout:
stderr:
printenv: illegal option -- -
usage: printenv [name]
assert 1 == 0
Root cause
The test runs dotenv run printenv --version and asserts it exits 0, to verify that dotenv run forwards flags to the wrapped command instead of parsing them itself (added in #607 / #612).
- On Linux,
printenvis GNU coreutils' version, which supports--versionand exits 0. - On macOS,
printenvis the BSD version, which does not support--versionat all, and exits 1 withprintenv: illegal option -- -.
So the test is actually working as intended (dotenv run correctly passes --version straight through to printenv rather than swallowing it), but the assertion only holds on systems with GNU printenv.
Why this hasn't been caught in CI
.github/workflows/test.yml only runs the test matrix on ubuntu-latest and windows-latest - there's no macos-latest job, so this has never surfaced there.
CONTRIBUTING.md tells contributors to just run tox or pytest, with no mention that the suite assumes a GNU userland / Linux, so a macOS contributor following the documented steps hits this with no explanation.
Suggested fix
Replace the OS-specific sentinel command (printenv --version) with something that behaves identically across GNU/BSD/Windows, e.g. a small python -c "..." snippet that just echoes its argv, so the test only cares about flag-forwarding behavior rather than a specific external tool's flag parsing.
Environment
- macOS (Darwin), tested via
toxlocally - Reproducible with plain
pytesttoo, since it's just calling the systemprintenv
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 600
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from theskumar/python-dotenv
-
An empty value ignores ${name:-default}Possibly taken @SashaMIT claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
theskumar/python-dotenv#715 ·
Maintainers usually reply within 1 day
-
set_key and unset_key don't fsync before replacing the .env filePossibly taken @Imkkey claimed this 9 days ago. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
theskumar/python-dotenv#713 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
theskumar/python-dotenv#693 · 1 comment ·
Maintainers usually reply within 1 day
-
python-dotenv installation without cli masks python-dotenv cliPossibly taken @gyanu2507 claimed this 48 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
theskumar/python-dotenv#683 · 4 comments ·
Maintainers usually reply within 1 day
-
Feature Request: Automatically copy `default.env` to `.env`Possibly taken @dradetsky claimed this 158 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
theskumar/python-dotenv#644 · 2 comments ·
Maintainers usually reply within 1 day
All issues in theskumar/python-dotenv
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NousResearch/hermes-agent#136483 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last elementPossibly taken @peterdsharpe claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pytorch/tensordict#2307 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
GrokModel.generate/a_generate pass an OpenAI-style list-of-dicts to xai_sdk.chat.user(), so every call crashes with a protobuf TypeError before any network I/OPossibly taken @Christian-Sidak claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
confident-ai/deepeval#3436 · 1 comment ·
Maintainers usually reply within 1 day