Skip to content

Module imports in scripts work only using absolute file path #5841

Description

@Yethal

Describe the bug

Trying to import a module in a standalone script using just the file name fails even though the module is placed in $env.NU_LIB_DIRS directory. The same script works just fine if module is imported using it's full file path

How to reproduce

  1. Create a module that exports a function
  2. Place the module in $env.NU_LIB_DIRS.0
  3. Create a script anywhere beside $env.NU_LIB_DIRS.0
  4. In the script place import statement at the top use modulename.nu *
  5. Try calling one of the exported functions in the script (this fails with module not found error)
  6. Replace the import statement with use full/path/to/module/file/modulename.nu *
  7. Try calling one of the exported functions in the script (this works just fine)

Expected behavior

I expected nu to be able to resolve the module path in a standalone script

Screenshots

No response

Configuration

key value
version 0.64.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.61.0 (fe5b13d68 2022-05-18)
cargo_version cargo 1.61.0 (a028ae4 2022-04-29)
pkg_version 0.64.0
build_time 2022-06-15 09:04:16 +02:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins gstat, inc, query, query json, query web, query xml

Additional context

No response

Activity

  1. added this to the v0.65 milestone on Jun 30, 2022
  2. modified the milestones: v0.65, v0.66.0 on Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions