Skip to content

Commit

Permalink
Remove "let config" warning (#10068)
Browse files Browse the repository at this point in the history
If you have a `config` variable defined at some point after reading
config files, Nushell would print
```
warning: use `$env.config = ...` instead of `let config = ...`
```

I think it's long enough since we've used `$env.config` that we can
remove this. Furthermore, it should be printed during `let` parsing
because you can end up with a `config` constant after importing a
`config` module (that was my case). The warning thus can be misleading.
  • Loading branch information
kubouch committed Aug 20, 2023
1 parent 10fc32e commit 66023f6
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/config_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use nu_cli::read_plugin_file;
use nu_cli::{eval_config_contents, eval_source};
use nu_path::canonicalize_with;
use nu_protocol::engine::{EngineState, Stack, StateWorkingSet};
use nu_protocol::{report_error, Span};
use nu_protocol::report_error;
use nu_protocol::{ParseError, PipelineData, Spanned};
use nu_utils::{get_default_config, get_default_env};
use std::fs::File;
Expand Down Expand Up @@ -203,19 +203,6 @@ pub(crate) fn setup_config(
if is_login_shell {
read_loginshell_file(engine_state, stack);
}

// Give a warning if we see `$config` for a few releases
{
let working_set = StateWorkingSet::new(engine_state);
if let Some(var) = working_set
.find_variable(b"$config")
.and_then(|id| stack.get_var(id, Span::unknown()).ok())
{
if var.as_record().is_ok() {
println!("warning: use `$env.config = ...` instead of `let config = ...`");
}
}
}
}

pub(crate) fn set_config_path(
Expand Down

0 comments on commit 66023f6

Please sign in to comment.