Repository navigation
docs(config,shell): correct etcetera macOS path docstrings - #2881
Conversation
choose_base_strategy() returns the Xdg strategy on every Unix platform (including macOS), so strategy.config_dir() resolves to $XDG_CONFIG_HOME (~/.config by default), never to ~/Library/Application Support. The ~/Library paths come from choose_native_strategy(); inside Apple, config_dir() is actually ~/Library/Preferences/ and ~/Library/Application Support/ is data_dir(). Three docstrings/comments told the opposite story. Comments-only — no behavior change. Refs #2878.
| /// — on macOS without `XDG_CONFIG_HOME` set, Nushell defaults to | ||
| /// `~/Library/Application Support/nushell`, otherwise it follows | ||
| /// `$XDG_CONFIG_HOME/nushell`. |
There was a problem hiding this comment.
| /// — on macOS without `XDG_CONFIG_HOME` set, Nushell defaults to | |
| /// `~/Library/Application Support/nushell`, otherwise it follows | |
| /// `$XDG_CONFIG_HOME/nushell`. | |
| /// — on macOS without `XDG_CONFIG_HOME` set, Nushell defaults to | |
| /// `$XDG_CONFIG_HOME/nushell`. |
There was a problem hiding this comment.
Thanks for taking a look! I'd like to keep the original wording — the suggested form drops the ~/Library/Application Support/nushell branch, and reads contradictorily ("without XDG_CONFIG_HOME set… defaults to $XDG_CONFIG_HOME/nushell").
Nushell's nu_config_dir() uses XDG_CONFIG_HOME only when it's set, non-empty, and absolute — otherwise it falls back to dirs::config_dir(), which on macOS is ~/Library/Application Support. So $nu.default-config-dir on macOS is:
$XDG_CONFIG_HOME/nushellwhen that var is set (to an absolute path)~/Library/Application Support/nushellotherwise
which is what the current docstring on the PR says. If you were aiming at something else (e.g. trimming the wording), happy to take another pass — let me know what you had in mind.
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks for the link. The page you cited actually shows the same macOS default the docstring describes — under "Configuration":
$nu.default-config-dir # macOS # => /Users/me/Library/Application Support/nushell # Linux # => /home/me/.config/nushell # Windows # => C:\Users\me\AppData\Roaming\nushell
That matches the source in nu_config_dir(): if XDG_CONFIG_HOME is set (non-empty, absolute) it wins; otherwise nushell falls back to dirs::config_dir(), which on macOS is ~/Library/Application Support. So the macOS default is ~/Library/Application Support/nushell, and $XDG_CONFIG_HOME/nushell only when that variable is set — exactly what the current docstring on this PR says.
If you saw something specific on that page that reads differently, could you quote the line? Happy to refine the wording, but I don't want to drop a branch that the cited docs explicitly confirm.
There was a problem hiding this comment.
@worktrunk-bot could we add tests to resolve any disagreement?
There was a problem hiding this comment.
Added in fe6cad8 — a new integration test, nushell_default_config_dir, that spawns nu -c "echo $nu.default-config-dir" and asserts both branches of the docstring against real Nushell:
nu_default_config_dir_uses_xdg_when_set(every Unix): withXDG_CONFIG_HOME=<tmp>/custom-xdg, asserts the output equals<tmp>/custom-xdg/nushell.nu_default_config_dir_macos_fallback_is_library_application_support(macOS only): withXDG_CONFIG_HOMEremoved, asserts the output equals$HOME/Library/Application Support/nushell.
Gated on shell-integration-tests since test-setup installs nu on every non-Windows runner. If the macOS test ever fails because nushell changed the fallback, that's the signal to revisit the docstring (and likely nu_path::nu_config_dir).
There was a problem hiding this comment.
@nnutter does this help with your concerns? (I v much appreciate you engaging here, and am happy to take on the tax of handling mistakes with the bot, etc. thank you)
There was a problem hiding this comment.
Yeah, I'm wrong about $nu.default-config-dir. I'll post over on the original issue some more info in case it helps.
Resolves the disagreement on #2881: `$nu.default-config-dir` honors `XDG_CONFIG_HOME` when set (cross-platform) and falls back to `~/Library/Application Support/nushell` on macOS otherwise — matching `nu_path::nu_config_dir` and what the docstring describes. Gated on `shell-integration-tests`; `nu` is installed by `.github/actions/test-setup` on every non-Windows runner. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
@nnutter would you be up for reviewing whether this is ready to go in? |
Summary
Fix docstrings/comments in
src/config/user/path.rsandsrc/shell/paths.rsthat misdescribe howetcetera'schoose_base_strategy()resolves paths on macOS.etcetera::choose_base_strategy()follows the CLI convention and returns theXdgstrategy on every Unix platform — including macOS. So:strategy.config_dir()on macOS =$XDG_CONFIG_HOME(default~/.config), not~/Library/Application Support.~/Library/...paths are whatchoose_native_strategy()returns (and also, perapple.rs,Apple::config_dir()is~/Library/Preferences/—~/Library/Application Support/isdata_dir()).Three places now told the reader the opposite of what the code does — flagged in #2878.
This PR is comments-only: the runtime behavior of
default_config_path(),nushell_config_dir(), andnushell_config_candidates()is unchanged. The deeper Nushell autoload-path bug discussed in #2878 (installing to$nu.default-config-dir/vendor/autoload/, which isn't an autoload directory) is independent and needs its own PR with an uninstall-side migration story.Test plan
cargo check --libtest (linux|macos|windows)