-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Make it possible to reference reusable module files from scripts #7247
Copy link
Copy link
Closed
Labels
category:enhancementNew feature or requestNew feature or request
Description
Related problem
The problem is described in the PR comment #6150 (comment). It looks to me that PR was intended to solve this problem, but I can't get this working.
Here is a simple example of having a script file and a module
# scripts/lib.nu
export def foo [] {}# scripts/main.nu
use lib.nu foo
fooWe can't call the script like this:
nu ./scripts/main.nu
Error: nu::parser::module_not_found (link)
× Module not found.
╭─[./scripts/main.nu:2:1]
2 │
3 │ use lib.nu foo
· ───┬──
· ╰── module not found
4 │
╰────
help: module files and their paths must be available before your script is run as parsing occurs before anything is evaluated
Describe the solution you'd like
I propose to make all use, overlay, source inside any .nu file reference paths relative to the script file itself instead of the process CWD. This is necessary to make robust split into multiple files and good shareable modules.
Describe alternatives you've considered
No response
Additional context and details
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
category:enhancementNew feature or requestNew feature or request