Repository: nushell/nushell
File: src/config_files.rs (Rust)

Code before:
use nu_protocol::{
    Config, ParseError, PipelineData, Spanned,
    engine::{EngineState, Stack, StateWorkingSet},
    eval_const::{get_user_autoload_dirs, get_vendor_autoload_dirs},
    report_parse_error, report_shell_error,
};
use nu_utils::{get_default_config, get_default_env, get_scaffold_config, get_scaffold_env};
use std::{
    fs,
    fs::File,
    io::{Result, Write},
    panic::{AssertUnwindSafe, catch_unwind},
    path::Path,
    sync::Arc,
};

const CONFIG_FILE: &str = "config.nu";
const ENV_FILE: &str = "env.nu";
const LOGINSHELL_FILE: &str = "login.nu";

pub(crate) fn read_config_file(
    engine_state: &mut EngineState,
    stack: &mut Stack,
    config_file: Option<Spanned<String>>,
    is_env_config: bool,
    create_scaffold: bool,
) {
    warn!(
        "read_config_file() config_file_specified: {:?}, is_env_config: {is_env_config}",
        &config_file
    );

    if is_env_config {
        eval_default_config(engine_state, stack, get_default_env(), is_env_config);
    } else {
        eval_default_config(engine_state, stack, get_default_config(), is_env_config);
    };

    warn!("read_config_file() loading_defaults is_env_config: {is_env_config}");

    // Load config startup file
    if let Some(file) = config_file {
        match engine_state.cwd_as_string(Some(stack)) {
            Ok(cwd) => {
                if let Ok(path) = canonicalize_with(&file.item, cwd) {
                    eval_config_contents(path, engine_state, stack);
                } else {
                    let e = ParseError::FileNotFound(file.item, file.span);
                    report_parse_error(&StateWorkingSet::new(engine_state), &e);
                }
            }

Review comment (suggestion):
I don't think this is working right. We're not getting the path of the file that was loaded. `Env at None` and `Config at None` doesn't seem right.

<img width="1399" height="422" alt="Image" src="https://github.com/user-attachments/assets/a9c9e275-dd7a-406a-a932-bc091b280b05" />

These should be listing the full path to the config.nu and env.nu that is getting loaded here.

Code after:
use nu_protocol::{
    Config, ParseError, PipelineData, Spanned,
    engine::{EngineState, Stack, StateWorkingSet},
    eval_const::{get_user_autoload_dirs, get_vendor_autoload_dirs},
    report_parse_error, report_shell_error,
};
use nu_utils::ConfigFileKind;
use std::{
    fs,
    fs::File,
    io::{Result, Write},
    panic::{AssertUnwindSafe, catch_unwind},
    path::Path,
    sync::Arc,
};

const LOGINSHELL_FILE: &str = "login.nu";

pub(crate) fn read_config_file(
    engine_state: &mut EngineState,
    stack: &mut Stack,
    config_file: Option<Spanned<String>>,
    config_kind: ConfigFileKind,
    create_scaffold: bool,
) {
    warn!("read_config_file() {config_kind:?} at {config_file:?}",);

    eval_default_config(engine_state, stack, config_kind);

    warn!("read_config_file() loading default {config_kind:?}");

    // Load config startup file
    if let Some(file) = config_file {
        match engine_state.cwd_as_string(Some(stack)) {
            Ok(cwd) => {
                if let Ok(path) = canonicalize_with(&file.item, cwd) {
                    eval_config_contents(path, engine_state, stack);
                } else {
                    let e = ParseError::FileNotFound(file.item, file.span);
                    report_parse_error(&StateWorkingSet::new(engine_state), &e);
                }
            }
            Err(e) => {
                report_shell_error(engine_state, &e);
            }
        }
    } else if let Some(mut config_path) = nu_path::nu_config_dir() {
        // Create config directory if it does not exist
        if !config_path.exists()
            && let Err(err) = std::fs::create_dir_all(&config_path)
        {