@@ -68,6 +68,15 @@ if [ -z "$USER_HOME" ]; then
68 USER_HOME="/home/${SSH_USER}"
68 USER_HOME="/home/${SSH_USER}"
72+ runuser -u "$SSH_USER" -- env HOME="$USER_HOME" "$@"
75+# Ensure user cache dirs are writable (mise writes under ~/.cache/mise)
76+install -d -m 700 -o "$SSH_USER" -g "$SSH_USER" "${USER_HOME}/.cache"
77+install -d -m 700 -o "$SSH_USER" -g "$SSH_USER" "${USER_HOME}/.cache/mise"
78+chown -R "$SSH_USER:$SSH_USER" "${USER_HOME}/.cache" 2>/dev/null || true
71# Home mount links (config-driven)
80# Home mount links (config-driven)
72__VIBEBOX_HOME_LINKS__
81__VIBEBOX_HOME_LINKS__
@@ -89,7 +98,7 @@ fi
89# Install Mise
98# Install Mise
90MISE_BIN="${USER_HOME}/.local/bin/mise"
99MISE_BIN="${USER_HOME}/.local/bin/mise"
91if [ ! -x "$MISE_BIN" ] && ! command -v mise >/dev/null 2>&1; then
100if [ ! -x "$MISE_BIN" ] && ! command -v mise >/dev/null 2>&1; then
92− curl https://mise.run | HOME="$USER_HOME" sh
101+ run_as_user sh -c 'curl https://mise.run | sh'
94echo 'eval "$(~/.local/bin/mise activate bash)"' >> "${USER_HOME}/.bashrc"
103echo 'eval "$(~/.local/bin/mise activate bash)"' >> "${USER_HOME}/.bashrc"
@@ -113,10 +122,11 @@ MISE
114touch "${USER_HOME}/.config/mise/mise.lock"
123touch "${USER_HOME}/.config/mise/mise.lock"
115if [ -x "$MISE_BIN" ]; then
124if [ -x "$MISE_BIN" ]; then
116− HOME="$USER_HOME" "$MISE_BIN" install
125+ run_as_user "$MISE_BIN" install
118− HOME="$USER_HOME" mise install
127+ run_as_user mise install
129+chown -R "$SSH_USER:$SSH_USER" "${USER_HOME}/.cache" "${USER_HOME}/.config/mise" "${USER_HOME}/.local/share/mise" 2>/dev/null || true
121# 3) start ssh (don't swallow failures)
131# 3) start ssh (don't swallow failures)
122# If ssh is already active, don't force start/restart.
132# If ssh is already active, don't force start/restart.