Skip to content

NU_LIB_DIRS environment variable no longer working #8870

Closed

Description

@kubouch

Describe the bug

Setting let-env NU_LIB_DIRS inside env.nu has no effect. Only const NU_LIB_DIRS works.

How to reproduce

  1. Inside env.nu: Set let-env NU_LIB_DIRS = [ ($nu.config-path | path dirname | path join 'scripts') ]
  2. const NU_LIB_DIRS is not set anywhere
  3. Put a file (script.nu) to the scripts folder
  4. source script.nu inside config.nu
  5. Error: File not found

Expected behavior

Should work the same as before.

Screenshots

No response

Configuration

key value
version 0.78.1
branch main
commit_hash 99c0a25
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.66.1 (90743e729 2023-01-10)
rust_channel 1.66.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.66.1 (ad779e08b 2023-01-10)
build_time 2023-04-13 00:14:22 +03:00
build_rust_channel release
features default, zip
installed_plugins from eml, from ics, from ini, from vcf, gstat, inc, query, query json, query web, query xml

Additional context

Activity

  1. added
    category:bug
    A:parser
    on Apr 13, 2023
  2. kubouch commented on Apr 13, 2023

    @kubouch
    ContributorAuthor

    Update: It's not related to the NU_LIB_DIRS PRs but at some point the way $nu.config-path is set changed. Now, it doesn't point at the default location anymore, but instead is set based on the --config flag and also resolves a symlink which is what caused my problem. Therefore, setting

    let-env NU_LIB_DIRS = [
        ($nu.config-path | path dirname | path join 'scripts')
    ]
    

    (as set in default env.nu) is not reliable anymore. We should probably have $nu.default-config-dir or something like that for this to keep working.

  3. fdncred commented on Apr 13, 2023

    @fdncred
    Contributor

    Maybe it was this PR #8792

  4. kubouch commented on Apr 13, 2023

    @kubouch
    ContributorAuthor

    Yeah, I think that PR is a good change, now we just need some way to refer to the default config location.

  5. ito-hiroki commented on Apr 13, 2023

    @ito-hiroki
    Contributor

    If no one is addressing this issue, I would like to.
    But I am just a little confused and want to make sure my understanding.
    I think the problem is that a user using a custom config directory (not default config dir /home/<username>/.config/nushell/) can't load scripts, which are placed in the default config dir, by using NU_LIB_DIRS now.
    Is it correct?

  6. kubouch commented on Apr 13, 2023

    @kubouch
    ContributorAuthor

    Yeah, if you look at the default env.nu lines I linked above, you see the NU_LIB_DIRS is derived from $nu.config-path which can change depending on multiple factors. So, we need some way to refer to the default config directory so that the NU_LIB_DIRS would always be pointing at /home/<username>/.config/nushell/scripts.

    The implementation should be quite easy: The $nu contents are defined during evaluation here and the implementation of the NuVariable is here.

  7. added this to the v0.79.0 milestone on Apr 15, 2023
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

    A:parsercategory:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions