fix(config): fall back to ~/.config/pup/config.yaml on macOS#538
Merged
Conversation
On macOS, dirs::config_dir() returns ~/Library/Application Support, not ~/.config. This caused config.yaml to be silently ignored when placed at the cross-platform path documented throughout the project. - Add config_file_candidates() that returns paths to try in priority order; on macOS (and only when PUP_CONFIG_DIR is not set), the XDG-style ~/.config/pup/config.yaml is appended as a fallback - Update load_config_file() to iterate candidates rather than read a single path - Add tests covering: primary path loaded, macOS XDG fallback present, PUP_CONFIG_DIR suppresses XDG fallback, config values applied via Config::from_env() - Update ARCHITECTURE.md to document platform-specific config paths Fixes #537 Co-Authored-By: Claude <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On macOS,
dirs::config_dir()returns~/Library/Application Supportrather than~/.config, so~/.config/pup/config.yaml(the path documented throughout the project) was silently ignored. This PR makes that path work as a fallback on macOS.Changes
src/config.rs: Addconfig_file_candidates()that returns config.yaml paths to try in priority order. On macOS, appends~/.config/pup/config.yamlas a second candidate — but only whenPUP_CONFIG_DIRis not set, so explicit overrides remain fully respected. (config.rs:276-297)src/config.rs: Updateload_config_file()to iterate candidates viafind_mapinstead of reading a single path. (config.rs:299-305)src/config.rs: Add four new tests: primary path is always first candidate, macOS XDG fallback is included,PUP_CONFIG_DIRsuppresses XDG fallback, and config values flow throughConfig::from_env().docs/ARCHITECTURE.md: Document the platform-specific config file locations.Testing
test_config_file_candidates_includes_primary— platform-independent: PUP_CONFIG_DIR path is first candidatetest_config_file_candidates_macos_includes_xdg_fallback— macOS-only: XDG path appears in candidatestest_config_file_candidates_macos_pup_config_dir_suppresses_xdg— macOS-only: explicit override suppresses fallbacktest_load_config_from_primary_path— end-to-end: site from config.yaml is picked up by Config::from_env()Related Issues
Closes #537
Generated by Claude Code