From 8784e88552ad7f6f6a9c149a739474e0b168a840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 15 Sep 2021 20:38:54 +0200 Subject: [PATCH] fix(core): use `$HOME/.cache` if default cache dir is non-writable (#10193) Fixes #10193 --- oh-my-zsh.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 442972a9a..cea466100 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -7,7 +7,12 @@ if [[ -z "$ZSH_CACHE_DIR" ]]; then ZSH_CACHE_DIR="$ZSH/cache" fi -# Create completions cache dir and add to $fpath +# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME +if [[ ! -w "$ZSH_CACHE_DIR" ]]; then + ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/ohmyzsh" +fi + +# Create cache and completions dir and add to $fpath mkdir -p "$ZSH_CACHE_DIR/completions" (( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)