mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:15:49 +02:00
Add nu lib dirs default (#11248)
# Description This PR is kind of two PRs in one because they were dependent on each other. PR1 -3de58d4dc2
with update7fcdb242d9
- This follows our mantra of having everything with defaults written in nushell rust code. So, that if you run without a config, you get the same behavior as with the default config/env files. This sets NU_LIB_DIRS to $nu.config-path/scripts and sets NU_PLUGIN_DIRS to $nu.config-path/plugins. PR2 -0e8ac876fd
- The benchmarks have been broke for some time and we didn't notice it. This PR fixes that. It's dependent on PR1 because it was throwing errors because PWD needed to be set to a valid folder and `$nu` did not exist based on how the benchmark was setup. I've tested the benchmarks and they run without error now and I've also launched nushell as `nu -n --no-std-lib` and the env vars exist. closes #11236 # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
27
src/main.rs
27
src/main.rs
@ -80,6 +80,33 @@ fn main() -> Result<()> {
|
||||
ctrlc_protection(&mut engine_state, &ctrlc);
|
||||
sigquit_protection(&mut engine_state);
|
||||
|
||||
// Begin: Default NU_LIB_DIRS, NU_PLUGIN_DIRS
|
||||
// Set default NU_LIB_DIRS and NU_PLUGIN_DIRS here before the env.nu is processed. If
|
||||
// the env.nu file exists, these values will be overwritten, if it does not exist, or
|
||||
// there is an error reading it, these values will be used.
|
||||
let nushell_config_path = if let Some(mut path) = nu_path::config_dir() {
|
||||
path.push("nushell");
|
||||
path
|
||||
} else {
|
||||
// Not really sure what to default this to if nu_path::config_dir() returns None
|
||||
std::path::PathBuf::new()
|
||||
};
|
||||
|
||||
let mut default_nu_lib_dirs_path = nushell_config_path.clone();
|
||||
default_nu_lib_dirs_path.push("scripts");
|
||||
engine_state.add_env_var(
|
||||
"NU_LIB_DIRS".to_string(),
|
||||
Value::test_string(default_nu_lib_dirs_path.to_string_lossy()),
|
||||
);
|
||||
|
||||
let mut default_nu_plugin_dirs_path = nushell_config_path;
|
||||
default_nu_plugin_dirs_path.push("plugins");
|
||||
engine_state.add_env_var(
|
||||
"NU_PLUGIN_DIRS".to_string(),
|
||||
Value::test_string(default_nu_plugin_dirs_path.to_string_lossy()),
|
||||
);
|
||||
// End: Default NU_LIB_DIRS, NU_PLUGIN_DIRS
|
||||
|
||||
// This is the real secret sauce to having an in-memory sqlite db. You must
|
||||
// start a connection to the memory database in main so it will exist for the
|
||||
// lifetime of the program. If it's created with how MEMORY_DB is defined
|
||||
|
Reference in New Issue
Block a user