Skip to content

fix: set HOME env var when not present in environment#713

Open
DC925928496 wants to merge 1 commit into
dbfixtures:mainfrom
DC925928496:fix/home-not-set
Open

fix: set HOME env var when not present in environment#713
DC925928496 wants to merge 1 commit into
dbfixtures:mainfrom
DC925928496:fix/home-not-set

Conversation

@DC925928496

@DC925928496 DC925928496 commented May 21, 2026

Copy link
Copy Markdown

Problem

RabbitMQ's Erlang runtime requires the HOME environment variable to be set. In stripped environments like tox (which unsets all env vars), the rabbitmq-server process fails with:

mirakuru.exceptions.ProcessExitedWithError: The process invoked by the
<pytest_rabbitmq.factories.process.RabbitMqExecutor: "rabbitmq-server">
executor has exited with a non-zero code: 1.

Captured stderr setup:
erlexec: HOME must be set

Users currently need a workaround in tox.ini:

setenv = HOME = {envtmpdir}

Fix

When HOME is not already present in os.environ, set it to the temporary directory path (path parameter) via envvars in RabbitMqExecutor.__init__. This is the same directory that RabbitMQ already uses for its runtime data (RABBITMQ_MNESIA_BASE), so it's a safe and appropriate fallback.

The fix is minimal — only 3 lines added to executor.py:

if "HOME" not in os.environ:
    envvars["HOME"] = str(path)

Related Issues

Fixes #37

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where the RabbitMQ executor would fail in environments where the HOME environment variable is stripped or missing.
  • Documentation

    • Corrected typos in parameter documentation.

Review Change Stack

RabbitMQ's Erlang runtime requires HOME to be set in the environment.
In stripped environments like tox, this causes the rabbitmq-server to fail
with 'HOME must be set'. Set HOME to the temporary directory path when
it is not already present in os.environ.

Fixes dbfixtures#37
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7754cbe1-45b6-46dd-b73a-3f2cb230f5cb

📥 Commits

Reviewing files that changed from the base of the PR and between 75a081f and 8d59bfd.

📒 Files selected for processing (1)
  • pytest_rabbitmq/factories/executor.py

📝 Walkthrough

Walkthrough

RabbitMQ executor initialisation now conditionally sets the HOME environment variable to the provided path when absent from os.environ, addressing environments where HOME is stripped. The os module is imported to support this, and parameter documentation is corrected.

Changes

HOME Environment Variable Initialisation

Layer / File(s) Summary
HOME environment variable initialisation
pytest_rabbitmq/factories/executor.py
Executor imports os, corrects path parameter docstring, and sets HOME to the provided path when missing from the process environment.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A HOME of one's own,
Now the fixture won't moan,
When tox strips it clean,
We set up the scene,
RabbitMQ's path now well-known!

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Newsfragment Check ⚠️ Warning No newsfragment file was added for this bug fix. This PR fixes issue #37 and requires a newsfragment of type 'bugfix' per the towncrier configuration in pyproject.toml. Create a newsfragment file: run pipenv run towncrier create 37.bugfix.rst with a brief description of the fix.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: setting the HOME environment variable when missing from the environment.
Linked Issues check ✅ Passed The code changes directly address issue #37 by implementing the proposed solution to set HOME to the temporary directory path when it is not present in os.environ.
Out of Scope Changes check ✅ Passed All changes are scoped to addressing the missing HOME environment variable issue; the docstring correction and import addition are directly related to this core objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pytest_rabbitmq/factories/executor.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@fizyk

fizyk commented May 21, 2026

Copy link
Copy Markdown
Member

@DC925928496
I'd also need a newsfragment and a test that would catch the issue here

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.

Fixture fails if HOME is not set

2 participants