Skip to content

Have $env.ENV_CONVERSIONS changes take place immediately #14514

@NotTheDr01ds

Description

@NotTheDr01ds

Related problem

Tossing this in so we don't lose track of it.

nu_engine::convert_env_values() is the function which handles ENV_CONVERSIONS for from_string. Currently, it has to be run "manually", so we do this several times during startup, basically whenever we know that we've changed, or assume that the user has changed, the $env.ENV_CONVERSIONS.

  1. Immediately after default_env.nu is evaluated, to pick up the PATH conversion in that file.
  2. Immediately before the user's config.nu so that any changes they've made in their env.nu can be used.
  3. After the user's env.nu in case they made any additional changes there.

Changes to the from_string in ENV_CONVERSIONS are never used.

Describe the solution you'd like

Things could be streamlined quite a bit if we run nu_engine::convert_env_values() any time that $env.ENV_CONVERSIONS is updated.

  1. We'd avoid a few potentially unnecessary calls.
  2. The user could change $env.ENV_CONVERSIONS and make use of them in the same file (e.g., config.nu). This could allow the user to go without an env.nu entirely in many cases.
  3. The user (or even third-party code) could update $env.ENV_CONVERSIONS at any point after startup and add new conversions.

Describe alternatives you've considered

No response

Additional context and details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:environmentRelated to the management of environment variables/process statecategory:enhancementNew feature or requeststatus:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions