Skip to content

ralphex-fe: rtk is never initialized when the container runs without /mnt/claude #128

Closed

Description

@gatezh

Split out of #125, which corrected the misleading comment but deliberately left the behaviour alone.

Problem

ralphex-fe/init-docker.sh initializes the rtk rewrite hook here:

if [ -d /mnt/claude ]; then
    ...
    if command -v rtk >/dev/null 2>&1; then
        RTK_TELEMETRY_DISABLED=1 gosu app timeout 10 rtk init -g --hook-only --auto-patch 2>/dev/null || true
    fi
fi

The rtk block sits inside the /mnt/claude guard. Until #125 the comment above it claimed the opposite:

Host mount usually brings the hook, but init idempotently to cover standalone usage (no host mount).

Standalone usage is exactly the case where /mnt/claude is absent, so the guard is false and rtk init never runs. A ralphex-fe container started without the host ~/.claude mount gets no PreToolUse rewrite hook at all — rtk is installed in the image (ralphex-fe/Dockerfile:141) and silently does nothing. No error, no log line: the 2>/dev/null || true on the invocation is moot because the invocation is never reached.

This is the only rtk init site in ralphex-fe.

Why #125 didn't fix it

Moving the rtk init call outside the guard is not a one-line move. The guard body also does:

mkdir -p /home/app/.claude
...
chown -R app:app /home/app/.claude

rtk init -g writes into $HOME/.claude and fails if the directory doesn't exist — confirmed locally:

rtk: Failed to create temp file in <HOME>/.claude: No such file or directory (os error 2)

So a correct fix has to hoist the mkdir -p and the chown out of the guard too, which is a behaviour change in the container's startup path. #125 is a docs(rtk): branch and shouldn't carry it.

Suggested fix

Restructure so the ~/.claude directory setup and the rtk init are unconditional, and only the credential/config copying stays behind if [ -d /mnt/claude ]:

mkdir -p /home/app/.claude

if [ -d /mnt/claude ]; then
    # copy config files, dirs, patch playwright MCP ...
fi

chown -R app:app /home/app/.claude

if command -v rtk >/dev/null 2>&1; then
    RTK_TELEMETRY_DISABLED=1 gosu app timeout 10 rtk init -g --hook-only --auto-patch < /dev/null 2>/dev/null || true
fi

Needs verification in an actual standalone ralphex-fe run (no -v ~/.claude:/mnt/claude), checking that /home/app/.claude/settings.json ends up with the rtk hook claude PreToolUse entry and that ownership is still correct.

Note the file header says it was "Copied as-is from umputun/ralphex. Check upstream for updates." — the rtk block is a local addition, so diverging here is fine, but worth keeping the local additions visually separated from the upstream body.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions