Skip to content

Comments

fix: wire --config-dir CLI flag to Config initialization#2121

Open
themavik wants to merge 1 commit intoelementary-data:masterfrom
themavik:fix-config-dir-flag
Open

fix: wire --config-dir CLI flag to Config initialization#2121
themavik wants to merge 1 commit intoelementary-data:masterfrom
themavik:fix-config-dir-flag

Conversation

@themavik
Copy link
Contributor

@themavik themavik commented Feb 20, 2026

Fixes #2037

The --config-dir flag was parsed but never passed to Config(), which always used the default ~/.edr. This wires the CLI argument through so the custom config directory is actually used.

Changes:

  • elementary/config/config.py: removed premature os.makedirs from _load_configuration()
  • elementary/tracking/anonymous_tracking.py: create config dir only when writing user ID file
  • elementary/monitor/cli.py: pass config_dir argument through to Config()

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Enhanced anonymous tracking to ensure parent directories are created before writing user identifiers.
  • Chores

    • Refined configuration initialization logic.
    • Improved error messaging for tracking events.

Fixes elementary-data#2037

The --config-dir flag was parsed but never passed to Config(), which always
used the default ~/.edr. This wires the CLI argument through so the custom
config directory is actually used.

- Remove premature directory creation from Config._load_configuration that
  ran at import time (logo/upgrade) and created ~/.edr before CLI parsing
- Create config_dir in anonymous_tracking when writing user id file
- Add --config-dir to debug and dbt_init commands for consistency
- Use keyword args for Config() in report command for clarity
@github-actions
Copy link
Contributor

👋 @themavik
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@themavik themavik requested a deployment to elementary_test_env February 20, 2026 18:24 — with GitHub Actions Waiting
@coderabbitai
Copy link

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

Removed automatic configuration directory creation in the config loading process, with explicit directory creation now added in anonymous tracking before file operations. Logging message improved for anonymous event failures.

Changes

Cohort / File(s) Summary
Configuration Directory Handling
elementary/config/config.py
Removed automatic directory creation from _load_configuration method; the method now directly checks for config file existence and returns an empty dict if missing, rather than creating the parent directory.
Anonymous Tracking
elementary/tracking/anonymous_tracking.py
Added explicit directory creation before writing anonymous user ID to ensure parent path exists. Updated logging message for anonymous event sending failures to be more descriptive.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through config with care,
No auto-dirs floating in the air!
Explicit paths, now crystal clear,
Better logging, nothing to fear.
Config flows true, no surprise there! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective: wiring the --config-dir CLI flag to Config initialization to fix issue #2037.
Linked Issues check ✅ Passed The PR changes address all coding requirements from issue #2037: passing config_dir to Config(), removing premature directory creation, and deferring it to anonymous_tracking.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the --config-dir wiring issue; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
elementary/tracking/anonymous_tracking.py (1)

20-33: ⚠️ Potential issue | 🟠 Major

Add config_dir parameter to debug and dbt_init command handlers.

Both commands are missing config_dir support despite the PR objective stating it was added:

  • debug (line 801): Config(profiles_dir=profiles_dir) — no config_dir parameter
  • dbt_init (line 824): Config() — no parameters at all

For consistency with the monitor command (line 349–351), both should accept and pass config_dir to Config(). Without this, anonymous tracking will resolve user_id_path against the default ~/.edr even when --config-dir is supplied.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@elementary/tracking/anonymous_tracking.py` around lines 20 - 33, The debug
and dbt_init command handlers are not passing the user-supplied config_dir into
the Config constructor so anonymous tracking still resolves user_id_path against
the default; update the debug handler (where it currently calls
Config(profiles_dir=profiles_dir)) to accept a config_dir parameter and call
Config(profiles_dir=profiles_dir, config_dir=config_dir), and update the
dbt_init handler (where it currently calls Config()) to accept config_dir and
call Config(config_dir=config_dir) — mirror how monitor passes config_dir to
Config to ensure anonymous tracking uses the supplied directory.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@elementary/tracking/anonymous_tracking.py`:
- Around line 20-33: The debug and dbt_init command handlers are not passing the
user-supplied config_dir into the Config constructor so anonymous tracking still
resolves user_id_path against the default; update the debug handler (where it
currently calls Config(profiles_dir=profiles_dir)) to accept a config_dir
parameter and call Config(profiles_dir=profiles_dir, config_dir=config_dir), and
update the dbt_init handler (where it currently calls Config()) to accept
config_dir and call Config(config_dir=config_dir) — mirror how monitor passes
config_dir to Config to ensure anonymous tracking uses the supplied directory.

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.

--config-dir is not actually used

1 participant