Add my_config() to Darwin drivers#10
Open
mjgardner wants to merge 1 commit intoperl5-utils:masterfrom
Open
Conversation
On macOS, ~/Library/Application Support is Apple's recommended location for both application configuration and data files. ~/Library/Preferences is reserved for CFPreferences/NSUserDefaults plists and is not suitable for arbitrary config files. Without my_config(), my_dist_config() falls back to my_documents(), which can resolve to unexpected locations (e.g., OneDrive-redirected ~/Documents on corporate machines). This makes my_dist_config() unreliable on macOS for its intended purpose. Changes: - Add my_config() to File::HomeDir::Darwin (pure Perl fallback) - Add my_config() to File::HomeDir::Darwin::Cocoa (Cocoa API) - Add my_config() dispatcher to File::HomeDir - Add my_config to @EXPORT_OK - Add tests for my_config in t/11_darwin.t and t/13_darwin_cocoa.t Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
On macOS,
my_dist_config()falls back tomy_documents()because neitherFile::HomeDir::DarwinnorFile::HomeDir::Darwin::Cocoaimplementsmy_config(). Frommy_dist_config():my_documents()returns~/Documents, which on corporate machines may be redirected to OneDrive or other cloud sync locations. This makesmy_dist_config()unreliable for its intended purpose on macOS.The FreeDesktop driver already implements
my_config()(returning$XDG_CONFIG_HOME), so Linux/BSD work correctly.Solution
Add
my_config()to the Darwin drivers, returning~/Library/Application Support— the same path asmy_data().This is Apple's recommended location for application configuration and data.
~/Library/Preferencesis reserved for CFPreferences/NSUserDefaults plists and isn't suitable for arbitrary config files (YAML, JSON, INI, etc.).Changes
File::HomeDir::Darwin— addmy_config()(pure Perl)File::HomeDir::Darwin::Cocoa— addmy_config()(viaNSApplicationSupportDirectory)File::HomeDir— addmy_config()dispatcher method and exportt/11_darwin.t— add test formy_config()t/13_darwin_cocoa.t— add test formy_config()All existing tests continue to pass (97 total on macOS, up from 95).