Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(wrapper): restore -u on Linux + guard USER_ARGS under set -u

AkitaOnRails7a04353ea02a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 02df1770..1dfef0db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+- **macOS thin-client wrapper no longer crashes with "Permission denied" in
+ the log file appender.** The `bin/ai-memory` wrapper passed
+ `-u $(id -u):$(id -g)` to the one-shot helper container, which on macOS
+ collides with the data volume owner (uid 1000 inside the container vs
+ uid 501/502 on the host). The wrapper now skips `-u` on Darwin so the
+ container runs as its default uid 1000 — Docker Desktop's file-sharing
+ layer handles host ownership transparently — while Linux and other
+ Unix systems continue to receive `-u`. Same change also hardens the
+ `${TTY_ARGS[@]}` / `${NETWORK_ARGS[@]}` / `${ENV_ARGS[@]}` /
+ `${USER_ARGS[@]}` expansions for `set -u` compatibility on macOS's
+ default bash 3.2 ([#51], thanks @abnersajr; supersedes [#50]).
+
## [0.7.0] - 2026-05-29
### Added
diff --git a/bin/ai-memory b/bin/ai-memory
index 4bc6e471..88d4ba1b 100755
--- a/bin/ai-memory
+++ b/bin/ai-memory
@@ -248,7 +248,10 @@ done
# 127.0.0.1 would mean "this helper container", so thin-client commands like
# `status` and `bootstrap` could not reach the default server.
NETWORK_ARGS=()
-USER_ARGS=()
+# Default: map the container process to the host user so files written
+# through bind mounts (~/.claude/settings.json, $PWD/, …) stay editable
+# by the invoking user. macOS is the one exception (see Darwin arm).
+USER_ARGS=(-u "$(id -u):$(id -g)")
case "$(uname -s 2>/dev/null || true)" in
Linux)
if [ -z "${AI_MEMORY_SERVER_URL:-}" ]; then
@@ -270,9 +273,6 @@ case "$(uname -s 2>/dev/null || true)" in
# which matches the volume owner.
USER_ARGS=()
;;
- *)
- USER_ARGS=(-u "$(id -u):$(id -g)")
- ;;
esac
# Mount the data dir at /data so commands that open the store
@@ -313,7 +313,7 @@ exec "${DOCKER}" run --rm ${TTY_ARGS[@]+"${TTY_ARGS[@]}"} \
-w /work \
-e HOME="${HOME}" \
-e AI_MEMORY_HOST_CWD="${PWD}" \
- "${USER_ARGS[@]}" \
+ ${USER_ARGS[@]+"${USER_ARGS[@]}"} \
"${DATA_ARGS[@]}" \
${ENV_ARGS[@]+"${ENV_ARGS[@]}"} \
"${IMAGE}" "$@"