pub struct NushellConfigDirs {
pub config_home: PathBuf,
pub config_file: ConfigPath,
pub env_file: ConfigPath,
pub data_home: PathBuf,
pub cache_home: PathBuf,
pub home_dir: PathBuf,
pub vendor_autoload_dirs: Vec<PathBuf>,
pub user_autoload_dirs: Vec<PathBuf>,
}Expand description
All resolved configuration directories and file paths for Nushell.
Every path here is the final answer after applying the full resolution chain: CLI overrides → XDG env vars → platform defaults.
This is the single source of truth for where config lives. Downstream
code (config-file loading, $nu constant generation, history backends,
plugin registry, etc.) must read from this struct instead of re-resolving.
§$nu constant
Most fields map to $nu.* members. See field docs for the mapping.
create_nu_constant() in nu-protocol reads from engine_state.config_dirs.
§Empty state
NushellConfigDirs::empty is used only before resolve_paths runs (or
when resolution fails). Check Self::is_resolved before treating paths
as meaningful.
Fields§
§config_home: PathBufThe nushell config directory (e.g. ~/.config/nushell).
Maps to $nu.default-config-dir.
config_file: ConfigPathPath to config.nu — either a CLI override (--config) or
config_home/config.nu. Maps to $nu.config-path.
env_file: ConfigPathPath to env.nu — either a CLI override (--env-config) or
config_home/env.nu. Maps to $nu.env-path.
data_home: PathBufThe nushell data directory (e.g. ~/.local/share/nushell).
Maps to $nu.data-dir.
cache_home: PathBufThe nushell cache directory (e.g. ~/.cache/nushell).
Maps to $nu.cache-dir.
home_dir: PathBufThe user’s home directory. Maps to $nu.home-dir.
vendor_autoload_dirs: Vec<PathBuf>Vendor autoload directories — directories from which Nushell
automatically loads .nu files at startup. These come from
XDG_DATA_DIRS, platform-specific paths, and $NU_VENDOR_AUTOLOAD_DIR.
Maps to $nu.vendor-autoload-dirs.
Order matters: files are evaluated in list order, so later entries
override earlier ones. On Unix, XDG_DATA_DIRS is reversed so that
earlier entries in the env var win (XDG precedence).
user_autoload_dirs: Vec<PathBuf>User autoload directories — config_home/autoload.
Maps to $nu.user-autoload-dirs.
Implementations§
Source§impl NushellConfigDirs
impl NushellConfigDirs
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty/inert instance for use before resolve_paths() has
been called (e.g. in EngineState::new()).
All paths are empty. Call resolve_paths() before accessing $nu.
Sourcepub fn is_resolved(&self) -> bool
pub fn is_resolved(&self) -> bool
Whether resolution produced usable paths (config home is non-empty).
Trait Implementations§
Source§impl Clone for NushellConfigDirs
impl Clone for NushellConfigDirs
Source§fn clone(&self) -> NushellConfigDirs
fn clone(&self) -> NushellConfigDirs
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more