Skip to main content

NushellConfigDirs

Struct NushellConfigDirs 

Source
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: PathBuf

The nushell config directory (e.g. ~/.config/nushell). Maps to $nu.default-config-dir.

§config_file: ConfigPath

Path to config.nu — either a CLI override (--config) or config_home/config.nu. Maps to $nu.config-path.

§env_file: ConfigPath

Path to env.nu — either a CLI override (--env-config) or config_home/env.nu. Maps to $nu.env-path.

§data_home: PathBuf

The nushell data directory (e.g. ~/.local/share/nushell). Maps to $nu.data-dir.

§cache_home: PathBuf

The nushell cache directory (e.g. ~/.cache/nushell). Maps to $nu.cache-dir.

§home_dir: PathBuf

The 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

Source

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.

Source

pub fn is_resolved(&self) -> bool

Whether resolution produced usable paths (config home is non-empty).

Trait Implementations§

Source§

impl Clone for NushellConfigDirs

Source§

fn clone(&self) -> NushellConfigDirs

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NushellConfigDirs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.