forked from extern/nushell
Revert "Allow NU_LIBS_DIR and friends to be const" (#8501)
Reverts nushell/nushell#8310 In anticipation that we may want to revert this PR. I'm starting the process because of this issue. This stopped working ``` let-env NU_LIB_DIRS = [ ($nu.config-path | path dirname | path join 'scripts') 'C:\Users\username\source\repos\forks\nu_scripts' ($nu.config-path | path dirname) ] ``` You have to do this now instead. ``` const NU_LIB_DIRS = [ 'C:\Users\username\AppData\Roaming\nushell\scripts' 'C:\Users\username\source\repos\forks\nu_scripts' 'C:\Users\username\AppData\Roaming\nushell' ] ``` In talking with @kubouch, he was saying that the `let-env` version should keep working. Hopefully it's a small change.
This commit is contained in:
@ -45,7 +45,7 @@ impl Command for Source {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// Note: this hidden positional is the block_id that corresponded to the 0th position
|
||||
// it is put here by the parser
|
||||
let block_id: i64 = call.req_parser_info(engine_state, stack, "block_id")?;
|
||||
let block_id: i64 = call.req_parser_info(engine_state, stack, 0)?;
|
||||
|
||||
let block = engine_state.get_block(block_id as usize).clone();
|
||||
eval_block_with_early_return(
|
||||
|
15
crates/nu-command/src/env/source_env.rs
vendored
15
crates/nu-command/src/env/source_env.rs
vendored
@ -1,8 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use nu_engine::{
|
||||
eval_block_with_early_return, find_in_dirs_env, get_dirs_var_from_call, redirect_env, CallExt,
|
||||
};
|
||||
use nu_engine::{eval_block_with_early_return, find_in_dirs_env, redirect_env, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
@ -44,15 +42,12 @@ impl Command for SourceEnv {
|
||||
|
||||
// Note: this hidden positional is the block_id that corresponded to the 0th position
|
||||
// it is put here by the parser
|
||||
let block_id: i64 = call.req_parser_info(engine_state, caller_stack, "block_id")?;
|
||||
let block_id: i64 = call.req_parser_info(engine_state, caller_stack, 0)?;
|
||||
|
||||
// Set the currently evaluated directory (file-relative PWD)
|
||||
let mut parent = if let Some(path) = find_in_dirs_env(
|
||||
&source_filename.item,
|
||||
engine_state,
|
||||
caller_stack,
|
||||
get_dirs_var_from_call(call),
|
||||
)? {
|
||||
let mut parent = if let Some(path) =
|
||||
find_in_dirs_env(&source_filename.item, engine_state, caller_stack)?
|
||||
{
|
||||
PathBuf::from(&path)
|
||||
} else {
|
||||
return Err(ShellError::FileNotFound(source_filename.span));
|
||||
|
@ -1,4 +1,4 @@
|
||||
use nu_engine::{find_in_dirs_env, get_dirs_var_from_call, CallExt};
|
||||
use nu_engine::{find_in_dirs_env, CallExt};
|
||||
use nu_parser::{parse, parse_module_block, unescape_unquote_string};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet};
|
||||
@ -106,12 +106,7 @@ impl Command for NuCheck {
|
||||
_ => {
|
||||
if let Some(path_str) = path {
|
||||
// look up the path as relative to FILE_PWD or inside NU_LIB_DIRS (same process as source-env)
|
||||
let path = match find_in_dirs_env(
|
||||
&path_str.item,
|
||||
engine_state,
|
||||
stack,
|
||||
get_dirs_var_from_call(call),
|
||||
) {
|
||||
let path = match find_in_dirs_env(&path_str.item, engine_state, stack) {
|
||||
Ok(path) => {
|
||||
if let Some(path) = path {
|
||||
path
|
||||
|
Reference in New Issue
Block a user