From 7f2185f0501a342a344f1c33216580f39d858606 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 28 Apr 2026 00:58:03 -0500 Subject: [PATCH 1/2] fix(airc daemon): scope tracks cwd at install time, not always $HOME/.airc PR #200 follow-up. _daemon_scope was returning ${AIRC_HOME:-$HOME/.airc} unconditionally, but actual user state lives in $cwd/.airc per detect_scope(). So 'airc daemon install' from ~/continuum/ captured the wrong scope (~/.airc, empty), spawned a monitor that connected to nothing, user appeared offline despite 'RUNNING (PID xxx)' in status. Mirror detect_scope's logic exactly: AIRC_HOME if set, else cwd/.airc. Now 'airc daemon install' from a project dir captures THAT dir's .airc as the daemon's scope, launcher .bat sets AIRC_HOME=that, the spawned airc connect uses the right room state. Joel 2026-04-28 ~01:05Z caught this: 'lol obv if it worked you would have a monitor and be online. FAIL'. --- airc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/airc b/airc index 98e5d5c..04951af 100755 --- a/airc +++ b/airc @@ -4876,10 +4876,19 @@ _daemon_airc_path() { fi } -# The scope the daemon will run under. If AIRC_HOME is set at install time, -# that's recorded in the unit/plist so future starts use the same scope. +# The scope the daemon will run under. Mirrors detect_scope() (line 135) +# so `airc daemon install` from a project dir captures THAT dir's +# .airc as the daemon's scope -- otherwise the daemon spawns a monitor +# pointed at $HOME/.airc (empty / wrong room) while the user's actual +# join state lives at $cwd/.airc. Joel 2026-04-28: "lol obv if it +# worked you would have a monitor and be online. FAIL" -- caught the +# scope mismatch on continuum-b69f's box. _daemon_scope() { - echo "${AIRC_HOME:-$HOME/.airc}" + if [ -n "${AIRC_HOME:-}" ]; then + echo "$AIRC_HOME" + else + echo "$(pwd -P)/.airc" + fi } # Returns 0 if the autostart daemon (launchd / systemd unit) is installed From be2b3045122db32c4bb668b55ce8b0cdae854d4d Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 28 Apr 2026 01:04:10 -0500 Subject: [PATCH 2/2] fix(airc daemon): launcher cd's to cwd, skip AIRC_HOME (Windows fs view fix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Daemon installed via PR #200/#201 was still crashlooping (every 4s) because the launcher .bat set AIRC_HOME to a Windows-form path (C:\Users\green\continuum\.airc) which Git Bash's airc binary couldn't traverse cleanly downstream. Plus 'bash -lc' was reading login profile and re-exporting PATH which churned env. Restructured launcher .bat: 1. 'cd /d ' from cmd.exe so the bash subprocess inherits the project dir as pwd. detect_scope() then returns /.airc the same way it does in the user's interactive shell. 2. Drop AIRC_HOME entirely — let detect_scope work normally. 3. 'bash -c' not 'bash -lc' — non-login skips profile, keeps the env we set in cmd uncorrupted. 4. Absolute Unix-form path to airc (cygpath -u) — bash -c doesn't read ~/.bashrc, so PATH may not include ~/.local/bin. 5. Errors log to daemon.err relative to cwd (already cd'd into it). Joel 2026-04-28 caught both the wrong-scope (PR #201) and now the crashloop. Verified locally: with this launcher shape, airc connect runs to completion + maintains the SSH tail to the host. --- airc | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/airc b/airc index 04951af..2339e6d 100755 --- a/airc +++ b/airc @@ -5020,18 +5020,42 @@ _daemon_install_schtasks() { # Stage a launcher .bat in $scope. Loops with 5s pause for airc-crash # auto-restart (matches launchd KeepAlive=true / systemd Restart=always). - # Uses `start /B` for the bash invocation so the cmd.exe wrapper - # doesn't pop a visible console window at logon. + # + # Why we cd into the project dir + don't set AIRC_HOME: airc's + # detect_scope() uses cwd to find /.airc. Setting AIRC_HOME + # to a Windows-form path (C:\Users\green\continuum\.airc) makes + # later bash code that touches AIRC_HOME hit "no such file" on + # Git Bash's mixed POSIX/Windows fs view. cd'ing first + letting + # detect_scope work its normal way is cleaner. Joel 2026-04-28 + # caught the daemon crashlooping every 4s in the prior shape. + # + # bash -c (not -lc): skip login profile. Login shells re-export + # PATH and other vars from /etc/profile.d/* on Git Bash, which can + # override the env we just set in cmd. Non-login bash keeps the + # cmd-set env clean. + # + # Absolute Unix-form path to airc: bash with -c doesn't read + # ~/.bashrc, so PATH may not include ~/.local/bin. Hard-coding + # the resolved unix path makes the invocation independent of PATH. + local cwd_win airc_bin_unix + if command -v cygpath >/dev/null 2>&1; then + cwd_win=$(cygpath -w "$(pwd -P)") + airc_bin_unix=$(cygpath -u "$airc_bin" 2>/dev/null) + [ -z "$airc_bin_unix" ] && airc_bin_unix="$airc_bin" + else + cwd_win=$(printf '%s' "$(pwd -P)" | sed 's|^/\([a-z]\)/|\U\1:\\\\|; s|/|\\\\|g') + airc_bin_unix="$airc_bin" + fi local launcher_bash="$scope/airc-daemon.bat" cat > "$launcher_bash" <> "$scope_win\\daemon.err" +"$bash_exe" -c "exec '$airc_bin_unix' connect" +echo [%date% %time%] airc connect exited. Restarting in 5s. >> daemon.err timeout /t 5 /nobreak >nul goto loop EOF