diff --git a/airc b/airc index 98e5d5c..2339e6d 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 @@ -5011,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