Skip to content

Allow EnvironmentVariableCollection to unset variables #185200

@mkhl

Description

@mkhl

EnvironmentVariableCollection currently support modifying a variable, or deleting a modification in that collection, but not unsetting an environment variable.

Sometimes we want to unset variables in the direnv extension but there is no API for it (and if we force null or undefined through the current API they get automatically stringified to "null" and "undefined").
The closest we can do is set them to the empty string (what POSIX calls null), but then some programs insist on distinguishing empty from undefined variables.
(N.B. Shells make this intentionally hard, for example the bash man page omits the expansion modifiers that distinguish null and unset variables.)

This could be done either by allowing null and/or undefined as the replacement value for replace, or with a new method on the API.

Related issue: direnv/direnv-vscode#527, and previously NixOS/nix#6409

Related commits: direnv/direnv-vscode@9905fe7, and previously direnv/direnv-vscode@79a4841

Metadata

Metadata

Assignees

Labels

apifeature-requestRequest for new features or functionalityterminal-processProblems launching processes, managing ptys, exiting, process leaks, etc.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions