Skip to content

GodotEnv skips adding zsh configuration if ~/.zshenv doesn't exist #199

Description

@wlsnmrk

When updating environment variables, GodotEnv tries to modify ~/.zshenv and skips it if it doesn't exist. I'm theorizing that design exists because the user likely doesn't have zsh installed if the file doesn't exist. However, if they do have zsh installed and the file doesn't exist (for instance, if they're only using ~/.zshrc), their configuration won't be updated.

It does appear, from cursory research, that .zshenv is preferable to .zshrc for our purposes, since .zshrc is for interactive shells and we may need access to GodotEnv environment variables in, e.g., login shells. (We've run across issues with bash login shells and VS Code on Arch Linux, for example). This Stack Exchange discussion contains some disagreement about the precise usage of various zsh config files, but .zshenv looks like a reasonable place for environment variables that are needed outside the context of interactive shells, and shouldn't require a logout/login or source.

Possible solutions:

  • Create ~/.zshenv on posix systems if it doesn't exist. If the user isn't using zsh, it doesn't do any harm.
    • Caveats:
      • The user may view it as harmful for us to create files that they don't need.
  • Give the user flags they can use to specify which shells they want updated.
    • Caveats:
      • Makes invoking godot env setup or godot install more complicated and failure-prone.
      • Keeping the existing behavior as a fallback retains the current path to silent configuration-update failures, but removing it breaks CLI compatibility.
  • ...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions