nushell / nushell/nushell

Nushell `--include` only includes for `--command` and not for scritps

Open
#11,578 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:needs-triage
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

Executing nu -I does not include the path to the lib dirs when executing a nu script but only if a command is executed.,

How to reproduce

Run the following nushell script:

print "Creating module in /tmp/sub_dir"
mkdir /tmp/sub_dir/my_module
"export def foo [] {print 'hello!'}" | save -f /tmp/sub_dir/my_module/mod.nu

# execute sub-shell
print "Including module in subshell as a command:"
^nu -I "/tmp/sub_dir" -n -c "use my_module *; foo"
print "Command works!"

print "Storing command as a script"
"use my_module *; foo" | save -f /tmp/script.nu

print "Executing from a script:"
print "will fail"
^nu -I "/tmp/sub_dir" -n /tmp/script.nu

Expected behavior

Given the documentation:

-I, --include-path <String> - set the NU_LIB_DIRS for the given script (delimited by char record_sep (''))

I would expect it to work for both scripts and single commands.

Screenshots

No response

Configuration
key value
version 0.89.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball)
cargo_version cargo 1.75.0
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, extra, sqlite, trash, which, zip
installed_plugins
Additional context

I, as a rust n00b not knowing the code-base, can't really see anything obvious that might indicate the behavior:
https://github.com/nushell/nushell/blob/ff290a5c3df4285a38ed3e8e84032206e0edb22c/src/main.rs#L204-L213

Happy to provide additional information/help if possible!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction script and inspect src/main.rs around lines 204-213, where the issue links to command-line handling. Run the shown -I examples to confirm the difference between -c and script execution. Done means the include path works consistently for both commands and scripts.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, shell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.