Skip to content

env.nu is being loaded when it shouldn't #5983

Closed

Description

@kubouch

Describe the bug

This bug was introduced by #5913. The existing env.nu is loaded with nu -c but it shouldn't.

How to reproduce

  1. Put print 'foo' into env.nu in the Nushell config directory
  2. Run nu -c '', it should print "foo"

Expected behavior

Shouldn't print foo. No user config should be read unless specified with command flags. It should load the default_env.nu instead.

Screenshots

No response

Configuration

key value
version 0.65.1
branch
commit_hash eac5f62
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.62.0 (a8314ef7d 2022-06-27)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.62.0 (a748cf5a3 2022-06-08)
pkg_version 0.65.1
build_time 2022-07-07 20:10:14 +03:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins gstat

Additional context

No response

Activity

  1. added
    category:bug
    on Jul 7, 2022
  2. WindSoilder commented on Jul 8, 2022

    @WindSoilder
    Contributor

    I'm sorry for introducing a bug like this :-(

    Do you mean we should do something like this?

    1. If user doesn't specify env config path, load default config, don't load user env config.
    2. If user specify env config path, load user env config, don't load default env config path.
  3. kubouch commented on Jul 8, 2022

    @kubouch
    ContributorAuthor

    Don't worry, that happens.

    Yes, exactly. Let's not load the same type of config twice. For clarity, when running nu -c:

    --env-config=env.nu --config=config.nu loads
    yes yes env.nu and config.nu
    yes no env.nu and nothing
    no yes default_env.nu and config.nu
    no no default_env.nu and nothing

    The question is should we load default_config.nu if no --config flag is passed but I think it's not necessary since most things defined there (completions, menus, keygbindings, table rendering, ...) do not impact the runtime.

    When running the interactive mode, it should never try to load the default env/config. Instead, it would try to read the user config location and if it does not exist, prompt the user to download the default config as it does now.

    --env-config=env.nu --config=config.nu loads
    yes yes env.nu and config.nu
    yes no env.nu and ~/.config/nushell/config.nu
    no yes ~/.config/nushell/env.nu and config.nu
    no no ~/.config/nushell/env.nu and ~/.config/nushell/config.nu

    At most, two configs should be read in the correct order: env config, then the normal config. I feel like in #5986 something is weird that maybe there are more config files being read and/or not read in the right order. Maybe the cause of the issue is the same as this one.

  4. fdncred commented on Jul 8, 2022

    @fdncred
    Contributor

    nice documentation in the tables here. How does any of this impact login.nu? It would be nice to clarify if that is being read/loaded every time, no matter what, if nushell is the login shell.

  5. kubouch commented on Jul 8, 2022

    @kubouch
    ContributorAuthor

    Ah, I forgot about login.nu. I guess that one should only be loaded when Nushell runs in a login mode which I think is activated with the nu -l flag. Not sure about the ordering of login.nu. Whatever makes sense -- I guess we can just keep the one that we have now.

  6. kubouch commented on Jul 14, 2022

    @kubouch
    ContributorAuthor

    Closed by #6040

  7. added this to the v0.66.0 milestone on Jul 14, 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