Skip to content

docs(config,shell): correct etcetera macOS path docstrings - #2881

Merged
max-sixty merged 2 commits into
mainfrom
fix/etcetera-path-docstrings-26326696076
Jun 6, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/etcetera-path-docstrings-26326696076

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Fix docstrings/comments in src/config/user/path.rs and src/shell/paths.rs that misdescribe how etcetera's choose_base_strategy() resolves paths on macOS.

etcetera::choose_base_strategy() follows the CLI convention and returns the Xdg strategy on every Unix platform — including macOS. So:

  • strategy.config_dir() on macOS = $XDG_CONFIG_HOME (default ~/.config), not ~/Library/Application Support.
  • The Apple/~/Library/... paths are what choose_native_strategy() returns (and also, per apple.rs, Apple::config_dir() is ~/Library/Preferences/ — ~/Library/Application Support/ is data_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(), and nushell_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 --lib
  • CI: test (linux|macos|windows)

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.
Comment thread src/shell/paths.rs
Comment on lines +60 to +62
/// — on macOS without `XDG_CONFIG_HOME` set, Nushell defaults to
/// `~/Library/Application Support/nushell`, otherwise it follows
/// `$XDG_CONFIG_HOME/nushell`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
/// — 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`.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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/nushell when that var is set (to an absolute path)
  • ~/Library/Application Support/nushell otherwise

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.

@nnutter nnutter May 23, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@worktrunk-bot could we add tests to resolve any disagreement?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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): with XDG_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): with XDG_CONFIG_HOME removed, 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).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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]>
@max-sixty

Copy link
Copy Markdown
Owner

@nnutter would you be up for reviewing whether this is ready to go in?

@nnutter nnutter left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The updated comments look accurate to me.

@max-sixty
max-sixty merged commit 08a8c26 into main Jun 6, 2026
55 of 56 checks passed
@max-sixty
max-sixty deleted the fix/etcetera-path-docstrings-26326696076 branch June 6, 2026 19:56
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.

3 participants