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

nix run unsets TMPDIR on macOS #7731

Open
roberth opened this issue Feb 1, 2023 · 0 comments
Open

nix run unsets TMPDIR on macOS #7731

roberth opened this issue Feb 1, 2023 · 0 comments
Labels
bug cli The old and/or new command line interface macos Nix on macOS, aka OS X, aka darwin new-cli Relating to the "nix" command

Comments

@roberth
Copy link
Member

roberth commented Feb 1, 2023

Describe the bug

initNix() clears an environment variable. It shouldn't.

Steps To Reproduce

$ echo TMPDIR=$TMPDIR; nix run nixpkgs#bash -- -c 'echo TMPDIR=$TMPDIR'                                                           ~
TMPDIR=/var/folders/vh/whk9gn015sd7vkh2php03jf80000gn/T/
TMPDIR=

Expected behavior

Darwin:

$ echo TMPDIR=$TMPDIR; nix run nixpkgs#bash -- -c 'echo TMPDIR=$TMPDIR'                                                           ~
TMPDIR=/var/folders/vh/whk9gn015sd7vkh2php03jf80000gn/T/
TMPDIR=/var/folders/vh/whk9gn015sd7vkh2php03jf80000gn/T/

Linux (already works, but the variable isn't even set in my session NixOS):

$ (export TMPDIR=/tmp; echo TMPDIR=$TMPDIR; nix run nixpkgs#bash -- -c 'echo TMPDIR=$TMPDIR')
TMPDIR=/tmp
TMPDIR=/tmp

nix-env --version output

Additional context

Potential duplicate of #395, although the solution hinted here does not have as broad a scope.

Found while working on a PR to be linked below.

Priorities

Add 👍 to issues you find important.

@roberth roberth added bug macos Nix on macOS, aka OS X, aka darwin new-cli Relating to the "nix" command cli The old and/or new command line interface labels Feb 1, 2023
roberth added a commit to hercules-ci/nix that referenced this issue Feb 1, 2023
This code is bad. We shouldn't unset variables in programs whose
children may need them. Fixing one issue at a time, so postponing.
See NixOS#7731
roberth added a commit to hercules-ci/nix that referenced this issue Feb 3, 2023
This code is bad. We shouldn't unset variables in programs whose
children may need them. Fixing one issue at a time, so postponing.
See NixOS#7731
roberth added a commit to hercules-ci/nix that referenced this issue Feb 5, 2023
This code is bad. We shouldn't unset variables in programs whose
children may need them. Fixing one issue at a time, so postponing.
See NixOS#7731
roberth added a commit to hercules-ci/nix that referenced this issue Feb 5, 2023
This code is bad. We shouldn't unset variables in programs whose
children may need them. Fixing one issue at a time, so postponing.
See NixOS#7731

Part of an effort to make it easier to initialize the right things,
by moving code into the appropriate libraries.
roberth added a commit to hercules-ci/nix that referenced this issue Apr 7, 2023
This code is bad. We shouldn't unset variables in programs whose
children may need them. Fixing one issue at a time, so postponing.
See NixOS#7731

Part of an effort to make it easier to initialize the right things,
by moving code into the appropriate libraries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cli The old and/or new command line interface macos Nix on macOS, aka OS X, aka darwin new-cli Relating to the "nix" command
Projects
None yet
Development

No branches or pull requests

1 participant