Skip to content

Conversation

@scaryrawr
Copy link
Member

BASH_ENV is a variable used for identifying a script that should be sourced when launching bash scripts.

zshenv is always sourced by zsh in interactive and non-interactive modes.

This makes it so that the auth wrapping functions are available in bash and zsh scripts.

`.zshenv` is sourced by all zsh shells (interactive/non-interactive/login).
Where `.zshrc` is only sourced by interactive shells.

To prevent users from having to be aware of auth wrappers,
using `.zshenv` will help reduce friction for users.
BASH_ENV is a variable used for identifying a script that should be sourced before launch bash scripts
@markphip markphip requested a review from Copilot March 23, 2025 17:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Files not reviewed (1)
  • src/artifacts-helper/install.sh: Language not supported

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

@markphip
Copy link
Contributor

Looks good overall. Can you update to bump the version to 2.0.4 and also review the content at the end of NOTES.md to see if there are any additional items about BASH_ENV you want to add to that documentation?

What scenario is this improving? It sounds like when a bash script runs a tool like npm or dotnet? I've also observed other scenarios like when a node app or some other code runs those tools without using a bash script. For example, the VS Code C# DevKit extension runs dotnet install and the bash customizations are not available when it does this. I am assuming this cannot help those situations.

@scaryrawr
Copy link
Member Author

What scenario is this improving? It sounds like when a bash script runs a tool like npm or dotnet?

This is correct, when running a bash script, the script will source the ~/.bashenv since BASH_ENV is set. Then scripts that use yarn, npm, or dotnet will have access to the functions that do the auth environment variable wrapping.

For example, the VS Code C# DevKit extension runs dotnet install and the bash customizations are not available when it does this. I am assuming this cannot help those situations.

The current solution does not work here... but I wonder if leveraging containerEnv in the devcontainer-feature.json would?

containerEnv is added before the feature is executed as ENV commands in the Dockerfile.

From docker:

The environment variables set using ENV will persist when a container is run from the resulting image.

I believe, then all bash scripts should see BASH_ENV and source the file.

BASH_ENV only works though if they are targeting bash, if it is targeting sh, I believe it will not source the file referenced by BASH_ENV.

@scaryrawr scaryrawr closed this Sep 30, 2025
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.

2 participants