Skip to content

Commit e11da4c

Browse files
MohsinHashmi-DataInnmohsin-wiserclaude
authored
fix(devcontainer): handle root user when creating maven wrapper dir (#334)
Script may run as root in devpod, so explicitly use /home/vscode and set proper ownership after creating the directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Mohsin Hashmi <mhashmi@wiser.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9ce425e commit e11da4c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.devcontainer/post-create.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ cd apps/backend
2727
if [ -f "./mvnw" ]; then
2828
chmod +x ./mvnw
2929
# Create Maven wrapper distribution directory (older wrapper versions don't create it)
30-
mkdir -p ~/.m2/wrapper/dists
30+
# Use vscode user's home explicitly since script may run as root
31+
MAVEN_USER_HOME="${MAVEN_USER_HOME:-/home/vscode}"
32+
mkdir -p "$MAVEN_USER_HOME/.m2/wrapper/dists" 2>/dev/null || mkdir -p ~/.m2/wrapper/dists 2>/dev/null || true
33+
# Ensure vscode owns the directory if we created it as root
34+
if [ "$(id -u)" = "0" ] && [ -d "$MAVEN_USER_HOME/.m2" ]; then
35+
chown -R vscode:vscode "$MAVEN_USER_HOME/.m2" 2>/dev/null || true
36+
fi
3137
./mvnw dependency:go-offline -B -q || true
3238
else
3339
mvn dependency:go-offline -B -q || true

0 commit comments

Comments
 (0)