Skip to content

make module imports in scripts used for relative path. - #5913

Merged
fdncred merged 2 commits into
nushell:mainfrom
WindSoilder:always_load_env
Jul 1, 2022
Merged

fdncred merged 2 commits into
nushell:mainfrom
WindSoilder:always_load_env

Conversation

@WindSoilder

@WindSoilder WindSoilder commented Jun 30, 2022 •

Copy link
Copy Markdown
Contributor

Description

Fixes: #5841

The issue is caused by when running nu script, env path is not loaded so NU_LIB_DIRS is not defined

Additional Note

It's conflict with #5544, especially the comment: #5544 (comment)

One argument against loading config by default when running scripts is portability. If you rely on implicit loading of your local config and send the script to your friend's machine, the friend won't be able to run it.

But I think load env makes more convenient to user who writing script with module, and it's less harmful to portability.

It also fixes config loading order, refer to doc:

Nushell uses a configuration system that loads+runs two Nushell script files at launch time: First, env.nu, then config.nu

Tests

Make sure you've done the following:

  • Add tests that cover your changes, either in the command examples, the crate/tests folder, or in the /tests folder.
  • Try to think about corner cases and various ways how your changes could break. Cover them with tests.
  • If adding tests is not possible, please document in the PR body a minimal example with steps on how to reproduce so one can verify your change works.

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 --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace --features=extra to check that all the tests pass

@WindSoilder
WindSoilder marked this pull request as draft June 30, 2022 08:30
@WindSoilder
WindSoilder marked this pull request as ready for review June 30, 2022 09:04
@fdncred

fdncred commented Jul 1, 2022

Copy link
Copy Markdown
Contributor

Thanks @WindSoilder

@fdncred
fdncred merged commit 6dde231 into nushell:main Jul 1, 2022
@WindSoilder
WindSoilder deleted the always_load_env branch July 8, 2022 03:11
kubouch added a commit that referenced this pull request Jul 10, 2022
kubouch added a commit that referenced this pull request Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module imports in scripts work only using absolute file path

2 participants