Skip to content

Commit 0cd351b

Browse files
JRemitzclaude
andcommitted
fix: --profile and --path now take priority over env vars
Previously REELN_CONFIG env var silently overrode --profile, so passing --profile fake-profile would load the env var's config file instead of failing with "not found". CLI arguments now always take priority: --path > --profile > REELN_CONFIG > REELN_PROFILE > default. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 61b5d78 commit 0cd351b

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

reeln/core/config.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,21 @@ def resolve_config_path(
371371
4. ``REELN_PROFILE`` environment variable
372372
5. Default XDG path (``~/.config/reeln/config.json``)
373373
"""
374-
if path is None:
375-
env_config = os.environ.get("REELN_CONFIG")
376-
if env_config:
377-
path = Path(env_config).expanduser()
378-
if path is None and profile is None:
379-
env_profile = os.environ.get("REELN_PROFILE")
380-
if env_profile:
381-
profile = env_profile
382-
return path or default_config_path(profile)
374+
# Explicit arguments take priority over env vars
375+
if path is not None:
376+
return path
377+
if profile is not None:
378+
return default_config_path(profile)
379+
380+
# Fall through to env vars
381+
env_config = os.environ.get("REELN_CONFIG")
382+
if env_config:
383+
return Path(env_config).expanduser()
384+
env_profile = os.environ.get("REELN_PROFILE")
385+
if env_profile:
386+
return default_config_path(env_profile)
387+
388+
return default_config_path()
383389

384390

385391
def load_config(

0 commit comments

Comments
 (0)