← Back to PRs

#3513: fix(docker): add MOLTBOT_STATE_DIR to resolve permission error

by Suksham-sharma open 2026-01-28 18:14 View on GitHub →
docker
## Summary - Adds `MOLTBOT_STATE_DIR=/home/node/.clawdbot` to both `moltbot-gateway` and `moltbot-cli` services in `docker-compose.yml` - Fixes the "EACCES: permission denied" error when running Docker install ## Root Cause When running in Docker, the app called `os.homedir()` to resolve the state directory (since `MOLTBOT_STATE_DIR` wasn't set). This returned `/home/node` based on the `HOME` env var, but the container user couldn't create nested directories properly due to volume mount permissions. ## Fix By explicitly setting `MOLTBOT_STATE_DIR=/home/node/.clawdbot`, the app now uses this path directly instead of deriving it from `os.homedir()`, correctly matching the mounted volume path. Fixes #3480 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the Docker onboarding path by explicitly setting `MOLTBOT_STATE_DIR=/home/node/.clawdbot` in `docker-compose.yml` for both gateway and CLI containers, and adjusts `docker-setup.sh` to `chown` the host-mounted config/workspace directories to uid/gid 1000. Together these changes aim to eliminate EACCES permission issues when the containerized app resolves its state directory (via `src/utils.ts`’s `resolveConfigDir`, which prefers `MOLTBOT_STATE_DIR`/`CLAWDBOT_STATE_DIR` over `os.homedir()`). Main concerns are around robustness/portability: `chown -R ... 2>/dev/null || true` can hide failures and recursively changes large trees, and hard-coding `/home/node/.clawdbot` couples compose to a specific image user/home layout. <h3>Confidence Score: 4/5</h3> - This PR is likely safe to merge, with minor portability/robustness caveats around Docker volume ownership and hard-coded paths. - Changes are small and localized to Docker setup, and align with existing config-dir resolution logic (`MOLTBOT_STATE_DIR`/`CLAWDBOT_STATE_DIR`). Remaining concerns are non-fatal but could lead to confusing behavior on non-Linux hosts or when directory trees are large (silent `chown` failure; recursive ownership changes; coupling compose to `/home/node`). - docker-setup.sh, docker-compose.yml <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs