Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make env option augment by default #11

Closed
ehmicky opened this issue Aug 22, 2024 · 1 comment · Fixed by #27
Closed

Make env option augment by default #11

ehmicky opened this issue Aug 22, 2024 · 1 comment · Fixed by #27

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented Aug 22, 2024

When a user sets environment variables, those should be extending the current ones, as opposed to redefining them. Just like the default behavior of Execa (extendEnv: true.

Reasons:

  1. This is what users most likely expect.
  2. This is how shells behave when running EXAMPLE_ENVVAR=value binary arg....
  3. This is how environment variables were designed: child processes inherit from their parent.
  4. When running a binary by its filename (as opposed to its file path), the PATH environment variable is needed. If the env option was to override the current environment variables (including PATH), most users will then get a ENOENT error, which might confuse them. Source: it just happens to me and it took me 30 seconds to realize what was going on.

Also, this can be implemented in very few bytes: {...process.env, ...options.env}.

I am also thinking that we don't need to expose any extendEnv option like Execa, since that's usually not needed, and in the spirit of keeping things small.

Thoughts?

@sindresorhus
Copy link
Owner

Yeah, let's try without exposing the option first.

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 a pull request may close this issue.

2 participants