pub(crate) fn setup_env(
    cli_args: &CliArgs,
    config: &Config,
    task: &str,
    home: Option<PathBuf>,
    time_summary_vec: &mut Vec<(String, u128)>,
) -> Result<EnvInfo, CargoMakeError> {
    envmnt::set_bool("CARGO_MAKE", true);
    envmnt::set("CARGO_MAKE_TASK", &task);

    envmnt::set("CARGO_MAKE_COMMAND", &cli_args.command);

    let task_arguments = match cli_args.arguments.clone() {
        Some(args) => args,
        None => vec![],
    };
    envmnt::set_list("CARGO_MAKE_TASK_ARGS", &task_arguments);

    // load duckscript_info
    let mut now = SystemTime::now();
    setup_env_for_duckscript();
    time_summary::add(time_summary_vec, "[Setup Env - Duckscript]", now);

    // load crate info
    now = SystemTime::now();
    let crate_info = if config.config.skip_crate_env_info.unwrap_or(false) {
        CrateInfo::new()
    } else {
        setup_env_for_crate(home.clone())?
    };
    time_summary::add(time_summary_vec, "[Setup Env - Crate Info]", now);

    // load git info
    now = SystemTime::now();
    let gitinfo = if config.config.skip_git_env_info.unwrap_or(false) {
        GitInfo::new()
    } else {
        setup_env_for_git_repo()
    };
    time_summary::add(time_summary_vec, "[Setup Env - Git]", now);

    // load rust info
    now = SystemTime::now();
    let rustinfo = if config.config.skip_rust_env_info.unwrap_or(false) {
        RustInfo::new()
    } else {
        setup_env_for_rust(home)
    };
    time_summary::add(time_summary_vec, "[Setup Env - Rust]", now);

    // load CI info
    now = SystemTime::now();
    let ci_info_struct = setup_env_for_ci();
    time_summary::add(time_summary_vec, "[Setup Env - CI]", now);

    // setup project info
    now = SystemTime::now();
    setup_env_for_project(config, &crate_info)?;
    time_summary::add(time_summary_vec, "[Setup Env - Project]", now);

    // load env vars
    now = SystemTime::now();
    initialize_env(config, &cli_args.arguments.clone().unwrap_or(vec![]))?;
    time_summary::add(time_summary_vec, "[Setup Env - Vars]", now);

    Ok(EnvInfo {
        rust_info: rustinfo,
        crate_info,
        git_info: gitinfo,
        ci_info: ci_info_struct,
    })
}
Sets up the env before the tasks execution.
src/lib/environment/mod.rs