From db7beefbe49d2ec6fa24ac98a2dad08eaf8f28e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 12 Aug 2022 09:25:37 +0300 Subject: [PATCH] c++: fall back to cache dir in /tmp rules_go is making calls that do `env - <...>` and are setting neither TMPDIR nor HOME. So we should always fallback somewhere. --- toolchain/defs.bzl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 73f8fda..965cf22 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -80,12 +80,15 @@ ZIG_TOOL_WRAPPER = """#!/usr/bin/env bash set -e if [[ -n "$TMPDIR" ]]; then - _cache_prefix=$TMPDIR + _cache_prefix=$TMPDIR +elif [[ -n "$HOME" ]]; then + if [[ "$(uname)" = Darwin ]]; then + _cache_prefix="$HOME/Library/Caches" + else + _cache_prefix="$HOME/.cache" + fi else - _cache_prefix="$HOME/.cache" - if [[ "$(uname)" = Darwin ]]; then - _cache_prefix="$HOME/Library/Caches" - fi + _cache_prefix=/tmp fi export ZIG_LOCAL_CACHE_DIR="$_cache_prefix/bazel-zig-cc"