Skip to content

fix: set HOME from user config for sync and log path resolution#247

Merged
mbabic84 merged 1 commit into
mainfrom
fix/sync-home-dir
Jul 12, 2026
Merged

fix: set HOME from user config for sync and log path resolution#247
mbabic84 merged 1 commit into
mainfrom
fix/sync-home-dir

Conversation

@mbabic84

Copy link
Copy Markdown
Owner

Summary

  • Fix ainstruct sync watcher not detecting new files by setting HOME before starting the sync process
  • Fix log entries being written to /root/.config/kilo-docker/logs/ instead of the user's log file

Problem

The container runs as root with HOME=/root. Two code paths used constants.GetHomeDir() (which reads $HOME) before the user's home directory was set:

  1. Sync watcher (ensureSyncForCurrentUser) — spawned kilo-entrypoint sync as root with HOME=/root, causing the watcher to monitor /root/.config/kilo/rules/ instead of /home/kd-<hash>/.config/kilo/rules/. New files were never detected.

  2. Log path (getLogFile) — initialized on first Log() call at main.go:476, before runUserInit set HOME. All entrypoint logs went to /root/.config/kilo-docker/logs/kilo-docker.log instead of the user's log file.

Solution

  • In main(): load user config via loadUserConfig() and set HOME before the first log call
  • In ensureSyncForCurrentUser(): set HOME before calling startSyncWithTokens()

Both match the existing pattern in runUserInit() at line 314.

Changes

  • cmd/kilo-entrypoint/main.go — Set HOME from user config at program start
  • cmd/kilo-entrypoint/userinit.go — Set HOME in ensureSyncForCurrentUser

Testing

  • Verified sync watcher detects and syncs new files (create + delete lifecycle)
  • Verified all log entries write to a single file under user's home
  • Verified sync process has correct HOME=/home/kd-8647b8 environment

Related

The sync watcher and log file path were resolved using $HOME which
defaults to /root in the container. This caused:
- Sync watcher monitoring /root/.config/kilo/ instead of the user's
  config directory, missing new file events
- Log entries written to /root/.config/kilo-docker/logs/ instead of
  the user's log file

Fix by loading user config and setting HOME before the first Log() call
in main(), and in ensureSyncForCurrentUser() before starting the sync
process.

Refs #245, #246
@mbabic84
mbabic84 merged commit 9b06e2a into main Jul 12, 2026
1 check passed
@mbabic84
mbabic84 deleted the fix/sync-home-dir branch July 12, 2026 15:18
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.49.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: update-config resolves HOME to /root instead of user home fix: backup/restore resolve HOME to /root instead of user home

1 participant