Skip to content

Fix circular-import crash when a project .env is missing#585

Merged
saleh-mir merged 1 commit into
masterfrom
fix/env-missing-dotenv-circular-import
Jun 7, 2026
Merged

Fix circular-import crash when a project .env is missing#585
saleh-mir merged 1 commit into
masterfrom
fix/env-missing-dotenv-circular-import

Conversation

@saleh-mir

Copy link
Copy Markdown
Member

jesse/services/env.py validates that a project .env exists at import time. When it's missing it called jh.error(...) — but jh.error()is_live()jesse.configjesse.modes.utilsjesse.services.loggerjesse.services.redis, and services.redis is exactly what imports env.py, so it's still mid-import. The result is a cryptic cannot import name 'sync_publish' from partially initialized module 'jesse.services.redis' ImportError that completely hides the intended ".env is missing" message.

(Surfaced while setting up the strategy-executor — Jesse running from a dir without a .env.)

Fix: print the message directly to stderr (no heavy import chain) + os._exit(1). The clear guidance now shows and the process exits cleanly.

  • Behaviour with a valid .env is unchanged.
  • Verified: from a no-.env dir it now prints the clear message + exits 1 (was: circular ImportError).
  • Full suite green (498 passed).

🤖 Generated with Claude Code

jesse/services/env.py validates that a project .env exists at import time and, if
missing, called jh.error(). But jh.error() -> is_live() -> jesse.config ->
jesse.modes.utils -> jesse.services.logger -> jesse.services.redis, and
services.redis is exactly what imports env.py — so it is still mid-import. The
result was a cryptic "cannot import name 'sync_publish' ... partially initialized
module 'jesse.services.redis'" ImportError that completely hid the intended
".env is missing" message.

Print the message directly to stderr (no heavy import chain) + os._exit(1), so the
clear guidance is shown and the process exits cleanly. Behaviour with a valid .env
is unchanged; full suite still green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@saleh-mir saleh-mir merged commit 3ed65ff into master Jun 7, 2026
15 checks passed
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.

1 participant