From a290c1fd63c86bb76e15228170de7eb3331851c9 Mon Sep 17 00:00:00 2001 From: Ryota Ikezawa Date: Fri, 19 Dec 2025 15:12:29 +0900 Subject: [PATCH] fix: add XDG fallback defaults to prevent permission errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When .zshenv is not sourced before .zshrc (which can happen on some systems), XDG variables would be empty, causing paths like ${XDG_CACHE_HOME}/devbox to resolve to /devbox, resulting in permission denied errors. Changes: - Add XDG Base Directory fallback exports at top of .zshrc - Disable ZDOTDIR in .zshenv to keep .zshrc at ~/.zshrc for simplicity 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- dot_zshenv.tmpl | 4 ++-- dot_zshrc.tmpl | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dot_zshenv.tmpl b/dot_zshenv.tmpl index 4b07a65..c158fb0 100644 --- a/dot_zshenv.tmpl +++ b/dot_zshenv.tmpl @@ -8,8 +8,8 @@ export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" -# Zsh config location -export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +# Zsh config location (disabled - using ~/.zshrc directly for simplicity) +# export ZDOTDIR="$XDG_CONFIG_HOME/zsh" # Locale export LANG=en_US.UTF-8 diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index c0a3d7f..41b4e9d 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -1,8 +1,16 @@ +# ============================================================================= +# XDG Base Directory (fallback if .zshenv not sourced) +# ============================================================================= +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" +export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" + # ============================================================================= # Instant prompt (show prompt immediately, load rest async) # ============================================================================= -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/starship/init.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/starship/init.zsh" +if [[ -r "${XDG_CACHE_HOME}/starship/init.zsh" ]]; then + source "${XDG_CACHE_HOME}/starship/init.zsh" fi # =============================================================================