FIX: load the library before anything else (#8774)

This commit is contained in:
Antoine Stevan 2023-04-06 20:21:33 +02:00 committed by GitHub
parent 74283c3ebc
commit d93953a56f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,6 +113,9 @@ pub(crate) fn run_commands(
) -> Result<(), miette::ErrReport> {
let mut stack = nu_protocol::engine::Stack::new();
let start_time = std::time::Instant::now();
load_standard_library(engine_state)?;
#[cfg(feature = "plugin")]
read_plugin_file(
engine_state,
@ -163,8 +166,6 @@ pub(crate) fn run_commands(
use_color,
);
load_standard_library(engine_state)?;
// Before running commands, set up the startup time
engine_state.set_startup_time(entire_start_time.elapsed().as_nanos() as i64);
let start_time = std::time::Instant::now();
@ -202,6 +203,8 @@ pub(crate) fn run_file(
let mut stack = nu_protocol::engine::Stack::new();
let start_time = std::time::Instant::now();
load_standard_library(engine_state)?;
#[cfg(feature = "plugin")]
read_plugin_file(
engine_state,
@ -252,8 +255,6 @@ pub(crate) fn run_file(
use_color,
);
load_standard_library(engine_state)?;
let start_time = std::time::Instant::now();
let ret_val = evaluate_file(
script_name,
@ -301,6 +302,8 @@ pub(crate) fn run_repl(
let mut stack = nu_protocol::engine::Stack::new();
let start_time = std::time::Instant::now();
load_standard_library(engine_state)?;
if parsed_nu_cli_args.no_config_file.is_none() {
setup_config(
engine_state,
@ -324,8 +327,6 @@ pub(crate) fn run_repl(
use_color,
);
load_standard_library(engine_state)?;
let start_time = std::time::Instant::now();
let ret_val = evaluate_repl(
engine_state,