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

cc-wrapper.sh: mktemp: command not found #316674

Open
cormacrelf opened this issue Jun 2, 2024 · 1 comment
Open

cc-wrapper.sh: mktemp: command not found #316674

cormacrelf opened this issue Jun 2, 2024 · 1 comment
Labels
0.kind: bug 6.topic: stdenv Standard environment

Comments

@cormacrelf
Copy link

Describe the bug

cc-wrapper.sh is not using Nix mktemp, it's expecting one to be in the environment. So it fails when you run it with an empty PATH.

This is happening because it's:

  1. Saving a PATH backup
  2. Setting PATH to nix's coreutils/bin:gnugrep:bin
  3. Using it for grep & cat etc
  4. Restoring the PATH backup
  5. Attempting to use mktemp

PATH="$path_backup"
# Old bash workaround, see above.
# if a cc-wrapper-hook exists, run it.
if [[ -e @out@/nix-support/cc-wrapper-hook ]]; then
compiler=@prog@
source @out@/nix-support/cc-wrapper-hook
fi
if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
responseFile=$(mktemp "${TMPDIR:-/tmp}/cc-params.XXXXXX")

Steps To Reproduce

  1. On pretty much any system:

    $ env - $(which nix) run nixpkgs#clang
    /nix/store/c1ib07kj7baid3s3wf5m98hcpbvgs8mk-clang-wrapper-16.0.6/bin/clang: line 249: mktemp: command not found

There is no step 2. You might encounter a situation like this when running Clang with a heavily stripped environment in a Remote Build Execution context.

Expected behavior

cc-wrapper should not error if the PATH is empty

Additional context

It looks to me like this is the root cause of #258608. Probably same with tweag/rules_nixpkgs#439.

Notify maintainers

No maintainers seem to be listed in cc-wrapper's metadata. But maybe @Artturin?

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
almost any system imaginable

Add a 👍 reaction to issues you find important.

@Artturin
Copy link
Member

Artturin commented Jun 2, 2024

#316700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: stdenv Standard environment
Projects
None yet
Development

No branches or pull requests

3 participants