#!/bin/bash set -euo pipefail # Actual Computer CLI Installer # Usage: curl -fsSL https://actual.inc/install?channel=stable | bash BASE_URL="https://dl.actual.inc" CHANNEL="stable" INSTALL_REPORTING=0 INSTALL_CHANNEL_CLASS="stable" INSTALL_SCRIPT="legacy_bash" INSTALL_SUPPORT_URL="https://dl.actual.inc/supported-platforms" INSTALL_STAGE=preflight INSTALL_REASON=unexpected_error INSTALL_OUTCOME=failed INSTALL_SIGNIN=not_attempted INSTALL_OS_BAND=unknown INSTALL_STARTED=0 INSTALL_FINISHED=0 INSTALL_CLOCK=$SECONDS INSTALL_FAILURE_MESSAGE="" INSTALL_DIAGNOSTIC_LOG="" INSTALL_DIAGNOSTIC_FIFO="" INSTALL_DIAGNOSTIC_REDACTOR_PID="" INSTALL_DOWNLOAD_SPINNER_PID="" OS=unknown ARCH=unknown BACKEND=unknown printf -v INSTALL_ATTEMPT '%04x%04x%04x%04x%04x%04x%04x%04x' "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" # The installer is commonly piped into Bash, where a successful run should not # drown out the useful final handoff. Saving the original streams first lets # the final summary and failure explanation remain visible after stdout/stderr # are redirected. The retained temporary file receives a sanitized stream, # never the raw command transcript. redact_install_diagnostics() { sed -E \ -e 's/(ac|aci|acr)_[[:alnum:]_-]+/[REDACTED_CREDENTIAL]/g' \ -e 's/([Aa]uthorization:[[:space:]]*([Bb]earer[[:space:]]*)?)[^[:space:]]+/\1[REDACTED]/g' \ -e 's/([Tt]oken|[Ss]ecret|[Pp]assword|[Aa]pi[_-]?[Kk]ey)([=:])[[:space:]]*[^[:space:]]+/\1\2[REDACTED]/g' } install_capture_diagnostics() { exec 3>&1 4>&2 if ! INSTALL_DIAGNOSTIC_LOG=$(mktemp "${TMPDIR:-/tmp}/actual-install.XXXXXX"); then INSTALL_DIAGNOSTIC_LOG="" return 0 fi INSTALL_DIAGNOSTIC_FIFO="${INSTALL_DIAGNOSTIC_LOG}.fifo" if ! mkfifo "${INSTALL_DIAGNOSTIC_FIFO}"; then rm -f "${INSTALL_DIAGNOSTIC_LOG}" || true INSTALL_DIAGNOSTIC_LOG="" INSTALL_DIAGNOSTIC_FIFO="" return 0 fi redact_install_diagnostics < "${INSTALL_DIAGNOSTIC_FIFO}" > "${INSTALL_DIAGNOSTIC_LOG}" 2>/dev/null & INSTALL_DIAGNOSTIC_REDACTOR_PID=$! exec >"${INSTALL_DIAGNOSTIC_FIFO}" 2>&1 } install_publish_success() { exec 1>&3 2>&4 } finish_diagnostic_capture() { # Restoring stdout/stderr closes the FIFO writer before waiting, so every # buffered line reaches the safe transcript before it is shown or retained. exec 1>&3 2>&4 if [ -n "${INSTALL_DIAGNOSTIC_REDACTOR_PID}" ]; then wait "${INSTALL_DIAGNOSTIC_REDACTOR_PID}" || true INSTALL_DIAGNOSTIC_REDACTOR_PID="" fi rm -f "${INSTALL_DIAGNOSTIC_FIFO}" 2>/dev/null || true INSTALL_DIAGNOSTIC_FIFO="" } install_set_stage() { INSTALL_STAGE="$1" INSTALL_REASON="$2" } install_failure_title() { case "${INSTALL_STAGE}" in download) echo "Download failed" ;; verify) echo "Verification failed" ;; extract) echo "Extraction failed" ;; install) echo "Installation failed" ;; startup) echo "Startup check failed" ;; compatibility) echo "Compatibility check failed" ;; preflight) echo "Installation prerequisites not met" ;; *) echo "Installation failed" ;; esac } install_failure_reason() { [ -n "${INSTALL_FAILURE_MESSAGE}" ] && { echo "${INSTALL_FAILURE_MESSAGE}" return 0 } case "${INSTALL_REASON}" in signature_invalid) echo "The downloaded package could not be verified." ;; archive_invalid) echo "The downloaded package is incomplete or invalid." ;; install_io_failed|permission_denied|disk_full) echo "The installer could not write to your user installation directory." ;; binary_startup_failed|runtime_prerequisite) echo "The installed client could not start on this system." ;; *) echo "The installer stopped unexpectedly." ;; esac } install_report() { [ "${INSTALL_REPORTING}" = 1 ] && [ "${ACTUAL_INSTALL_TELEMETRY:-1}" != 0 ] || return 0 command -v curl >/dev/null 2>&1 || return 0 local event="$1" outcome="$INSTALL_OUTCOME" reason="$INSTALL_REASON" signin="$INSTALL_SIGNIN" local os="$OS" arch="$ARCH" backend="$BACKEND" elapsed body case "$os" in darwin|linux|windows|unknown) ;; *) os=other ;; esac case "$arch" in x86_64|aarch64|unknown) ;; *) arch=other ;; esac case "$backend" in metal|cuda|rocm|unknown) ;; *) backend=other ;; esac if [ "$event" = started ]; then outcome=started; reason=none; signin=not_attempted; fi elapsed=$(( (SECONDS - INSTALL_CLOCK) * 1000 )) [ "$elapsed" -ge 0 ] || elapsed=0 [ "$elapsed" -le 172800000 ] || elapsed=172800000 printf -v body '{"version":1,"attempt":"%s","event":"%s","outcome":"%s","os":"%s","arch":"%s","backend":"%s","os_band":"%s","channel":"%s","script":"%s","stage":"%s","reason":"%s","signin":"%s","duration_ms":%s}' "$INSTALL_ATTEMPT" "$event" "$outcome" "$os" "$arch" "$backend" "$INSTALL_OS_BAND" "$INSTALL_CHANNEL_CLASS" "$INSTALL_SCRIPT" "$INSTALL_STAGE" "$reason" "$signin" "$elapsed" curl -sS --proto '=https' --tlsv1.2 --connect-timeout 1 --max-time 1 --retry 0 \ -H 'Content-Type: application/json' --data-binary "$body" "${BASE_URL}/install-report" >/dev/null 2>&1 || true } install_started() { if [ "$INSTALL_STARTED" = 0 ]; then INSTALL_STARTED=1 install_report started fi } install_finish() { local status="$1" [ "$INSTALL_FINISHED" = 0 ] || return 0 INSTALL_FINISHED=1 stop_download_spinner if [ "$status" = 0 ]; then INSTALL_OUTCOME=installed INSTALL_REASON=none INSTALL_STAGE='done' fi finish_diagnostic_capture install_started if [ "$status" != 0 ]; then install_failure_title >&4 install_failure_reason >&4 # Capture is intentionally best effort: a read-only or unusual temporary # directory must not hide the original installer error or advertise a log # that was never safely created. if [ -n "${INSTALL_DIAGNOSTIC_LOG}" ] && [ -f "${INSTALL_DIAGNOSTIC_LOG}" ]; then echo "Diagnostic log at: ${INSTALL_DIAGNOSTIC_LOG}" >&4 fi echo "Please submit a bug report at https://actual.inc/" >&4 fi install_report finished if [ "$status" = 0 ]; then rm -f "${INSTALL_DIAGNOSTIC_LOG}" 2>/dev/null || true fi } install_fail() { INSTALL_REASON="$1" INSTALL_FAILURE_MESSAGE="$2" INSTALL_OUTCOME="${3:-failed}" echo "Error: $2" >&2 exit 1 } trap 'install_finish "$?"' EXIT trap 'INSTALL_REASON=interrupted; exit 130' INT trap 'INSTALL_REASON=interrupted; exit 143' TERM stop_download_spinner() { if [ -n "${INSTALL_DOWNLOAD_SPINNER_PID}" ]; then kill "${INSTALL_DOWNLOAD_SPINNER_PID}" 2>/dev/null || true wait "${INSTALL_DOWNLOAD_SPINNER_PID}" 2>/dev/null || true INSTALL_DOWNLOAD_SPINNER_PID="" printf '\r\033[K' >&4 fi } download_install_file() { local url="$1" destination="$2" status rc=0 reason # Curl's errors can contain the install credential, so keep them in the # redacted log and send only this fixed message to the terminal. if [ -t 4 ]; then ( while :; do for frame in '|' '/' '-' "\\"; do printf '\r%s Downloading Actual...' "$frame" >&4 sleep 0.1 done done ) & INSTALL_DOWNLOAD_SPINNER_PID=$! fi status=$(curl -fL --proto '=https' --tlsv1.2 --progress-bar \ --connect-timeout 15 --max-time 600 -D "${TMP_DIR}/download.headers" \ -w '%{http_code}' "$url" -o "$destination") || rc=$? stop_download_spinner if [ "$rc" = 0 ] && [[ "$status" =~ ^2[0-9][0-9]$ ]]; then return 0; fi reason=$(awk 'tolower($1) == "x-actual-download-reason:" { value=$2 } END { gsub(/\r/, "", value); print value }' "${TMP_DIR}/download.headers" 2>/dev/null || true) case "$status" in 401) install_fail authentication_required "Download authorization is missing or expired. Obtain a fresh install command and retry." ;; 403) install_fail access_denied "This install command cannot access the selected release. Check your account access or obtain a fresh command." ;; 404) if [ "$reason" = channel_not_found ]; then install_fail channel_not_found "The selected release channel is not available. Check the install command or retry later." fi install_fail artifact_not_found "The selected build is not available in this release. Your hardware may be supported; retry the release later." ;; 5??) install_fail download_unavailable "The download service is temporarily unavailable. Retry later." ;; esac case "$rc" in 28) install_fail download_timeout "The download timed out. Check your network and retry." ;; 35|51|58|60) install_fail tls_failed "A secure download connection could not be verified. Check the system clock, certificates, and network." ;; *) install_fail download_failed "Check your network and retrieve another install code." ;; esac } macos_version_number() { local value="$1" major minor patch [[ "$value" =~ ^[0-9]{1,3}(\.[0-9]{1,3}){0,2}$ ]] || return 1 IFS=. read -r major minor patch <<< "$value" major=$((10#$major)); minor=$((10#${minor:-0})); patch=$((10#${patch:-0})) [ "$minor" -le 255 ] && [ "$patch" -le 255 ] || return 1 echo $((major * 65536 + minor * 256 + patch)) } read_macho_u32() { od -An -j "$2" -N 4 -tu4 "$1" 2>/dev/null | tr -d ' \n' } macho_macos_minimum() { local binary="$1" magic count size offset=32 index=0 cmd length value platform magic=$(read_macho_u32 "$binary" 0) || return 1 # Published Apple Silicon binaries are thin, little-endian Mach-O 64 files. [ "$magic" = 4277009103 ] || return 1 count=$(read_macho_u32 "$binary" 16) || return 1 size=$(read_macho_u32 "$binary" 20) || return 1 [[ "$count" =~ ^[0-9]+$ && "$size" =~ ^[0-9]+$ ]] || return 1 [ "$count" -le 512 ] && [ "$size" -le 65536 ] || return 1 while [ "$index" -lt "$count" ]; do cmd=$(read_macho_u32 "$binary" "$offset") || return 1 length=$(read_macho_u32 "$binary" "$((offset + 4))") || return 1 [[ "$cmd" =~ ^[0-9]+$ && "$length" =~ ^[0-9]+$ ]] || return 1 [ "$length" -ge 8 ] && [ "$((offset + length))" -le "$((32 + size))" ] || return 1 if [ "$cmd" = 50 ] && [ "$length" -ge 24 ]; then platform=$(read_macho_u32 "$binary" "$((offset + 8))") || return 1 [ "$platform" = 1 ] || return 1 value=$(read_macho_u32 "$binary" "$((offset + 12))") || return 1 [[ "$value" =~ ^[0-9]+$ ]] && [ "$value" -gt 0 ] || return 1 echo "$value"; return 0 elif [ "$cmd" = 36 ] && [ "$length" -ge 16 ]; then value=$(read_macho_u32 "$binary" "$((offset + 8))") || return 1 [[ "$value" =~ ^[0-9]+$ ]] && [ "$value" -gt 0 ] || return 1 echo "$value"; return 0 fi offset=$((offset + length)); index=$((index + 1)) done return 1 } validate_package_macos() { [ "$OS" = darwin ] || return 0 local package="$1" detected current required=0 binary minimum unverified=0 install_set_stage compatibility "$INSTALL_REASON" detected=$(sw_vers -productVersion 2>/dev/null || true) if ! current=$(macos_version_number "$detected"); then echo "Warning: the macOS version could not be verified. Package compatibility is unverified." >&2 return 0 fi for binary in "$package/actual" "$package/actual-daemon" "$package/actual-menubar" "$package/malibu-serve" "$package/aci-server" "$package"/lib*.dylib*; do [ -f "$binary" ] || continue if minimum=$(macho_macos_minimum "$binary"); then if [ "$minimum" -gt "$required" ]; then required="$minimum"; fi else unverified=1 fi done if [ "$required" -gt "$current" ]; then install_fail unsupported_os_version "This package requires macOS $((required / 65536)).$(((required / 256) % 256)).$((required % 256)) or newer; detected ${detected}. Update macOS before retrying." blocked fi if [ "$required" = 0 ] || [ "$unverified" = 1 ]; then echo "Warning: some package OS requirements could not be verified. Keep any startup error for support." >&2 fi } check_install_startup() { local error_file install_set_stage startup binary_startup_failed error_file=$(mktemp "${TMP_DIR}/.startup.XXXXXX") if ! "$1" --version > /dev/null 2> "$error_file"; then cat "$error_file" >&2 if grep -Eq 'GLIBC_|GLIBCXX_|CXXABI_|Library not loaded|incompatible.*architecture' "$error_file"; then INSTALL_REASON=runtime_prerequisite INSTALL_OUTCOME=blocked fi echo "Error: Actual client could not start. Fix the prerequisite issue above and rerun the installer." >&2 exit 1 fi } check_install_space() { local destination="$1" required available install_set_stage install install_io_failed while [ ! -e "$destination" ]; do destination=$(dirname "$destination"); done if [ ! -d "$destination" ] || [ ! -w "$destination" ]; then install_fail permission_denied "The user installation directory is not writable. Check its permissions and retry." fi required=$(du -sk "$TMP_DIR" 2>/dev/null | awk '{print $1}') || return 0 available=$(df -Pk "$destination" 2>/dev/null | awk 'END {print $4}') || return 0 if [[ "$required" =~ ^[0-9]+$ && "$available" =~ ^[0-9]+$ ]] && [ "$available" -lt "$required" ]; then install_fail disk_full "There is not enough free disk space to install this package. Free disk space and retry." fi } install_capture_diagnostics case "$(uname -s)" in Darwin) OS=darwin ;; Linux) OS=linux ;; *) OS=other; install_fail unsupported_os "No Actual build is available for $(uname -s). See $INSTALL_SUPPORT_URL." blocked ;; esac case "$(uname -m)" in x86_64|amd64) ARCH=x86_64 ;; arm64|aarch64) ARCH=aarch64 ;; *) ARCH=other; install_fail unsupported_architecture "No Actual build is available for architecture $(uname -m). See $INSTALL_SUPPORT_URL." blocked ;; esac if [ "$OS" = darwin ]; then if [ "$ARCH" = x86_64 ] && [ "$(sysctl -n hw.optional.arm64 2>/dev/null || true)" = 1 ]; then ARCH=aarch64; fi MACOS_VERSION=$(sw_vers -productVersion 2>/dev/null || true) case "$MACOS_VERSION" in 11.*|12.*) INSTALL_OS_BAND=macos_11_12 ;; 13.*|14.*|15.*) INSTALL_OS_BAND=macos_13_15 ;; 26.*|27.*|28.*|29.*) INSTALL_OS_BAND=macos_26_plus ;; "") INSTALL_OS_BAND=unknown ;; *) INSTALL_OS_BAND=other ;; esac fi BACKEND="${ACTUAL_BACKEND:-}" if [ -z "$BACKEND" ]; then if [ "$OS" = darwin ]; then BACKEND=metal elif [ -d /opt/rocm ] || command -v rocminfo >/dev/null 2>&1 || command -v hipconfig >/dev/null 2>&1; then BACKEND=rocm else BACKEND=cuda; fi fi install_started case "$OS-$ARCH-$BACKEND" in darwin-aarch64-metal|linux-x86_64-cuda|linux-x86_64-rocm|linux-aarch64-cuda) ;; darwin-x86_64-*) install_fail unsupported_architecture "Actual Computer is not available for macOS on Intel (x86_64). It requires a Mac with Apple Silicon (M1 or later)." blocked ;; linux-aarch64-rocm) install_fail unsupported_backend "ROCm builds are only available for Linux x86_64. No aarch64 ROCm artifact is published. Use a supported NVIDIA CUDA system or Linux x86_64 with ROCm." blocked ;; *) install_fail unsupported_backend "Actual Computer is not available for $OS on $ARCH with ACTUAL_BACKEND=$BACKEND. See $INSTALL_SUPPORT_URL." blocked ;; esac for required_tool in curl tar; do command -v "$required_tool" >/dev/null 2>&1 || install_fail missing_tool "Install the required tool '$required_tool' and retry." done # Backend suffix on the artifact name. ROCm artifacts ship under # actual---rocm.; CUDA / Metal builds use the bare name. case "${BACKEND}" in rocm) ARTIFACT_SUFFIX="-rocm" ;; *) ARTIFACT_SUFFIX="" ;; esac ARTIFACT="actual-${OS}-${ARCH}${ARTIFACT_SUFFIX}.tar.gz" DOWNLOAD_URL="${BASE_URL}/actual/client/${CHANNEL}/${ARTIFACT}" echo "Installing Actual Computer CLI..." echo " OS: ${OS}" echo " Arch: ${ARCH}" echo " Backend: ${BACKEND}" # Create temp directory TMP_DIR=$(mktemp -d) INSTALL_STAGE_DIR="" cleanup_install() { status=$? install_finish "$status" # Cleanup is best-effort: it must never replace the install result that led # to this EXIT trap, even if the filesystem rejects a removal. rm -rf "${TMP_DIR}" "${INSTALL_STAGE_DIR}" || true exit "${status}" } trap cleanup_install EXIT # Download and extract. The transport flags below require curl >= 7.34 # (2013); every supported platform ships far newer, and older curl fails # loudly here rather than silently downgrading. install_set_stage download download_failed echo "Downloading..." download_install_file "${DOWNLOAD_URL}" "${TMP_DIR}/${ARTIFACT}" install_set_stage extract archive_invalid echo "Extracting..." tar -xzf "${TMP_DIR}/${ARTIFACT}" -C "${TMP_DIR}" if [ ! -f "${TMP_DIR}/actual" ]; then echo "Error: tarball did not contain ./actual at the root" >&2 ls -la "${TMP_DIR}" >&2 exit 1 fi # Install to ~/.actual/bin (user-writable, no sudo needed for updates). # Stable archives can be either the old single-binary layout (./actual only) # or the newer multi-binary layout (./actual + ./actual-daemon + optional # macOS ./actual-menubar), plus optionally bundled shared libraries alongside. # We copy shared libraries into INSTALL_DIR so the binary's rpath=$ORIGIN # resolves at runtime. validate_package_macos "${TMP_DIR}" check_install_startup "${TMP_DIR}/actual" check_install_space "${HOME}/.actual/bin" install_set_stage install install_io_failed INSTALL_DIR="${HOME}/.actual/bin" mkdir -p "${INSTALL_DIR}" ACTUAL_BINARY_PATH="${INSTALL_DIR}/actual-bin" ACTUAL_DAEMON_PATH="${INSTALL_DIR}/actual-daemon" ACTUAL_MENUBAR_PATH="${INSTALL_DIR}/actual-menubar" ACTUAL_CMD="${INSTALL_DIR}/actual" INSTALL_STAGE_DIR="$(mktemp -d "${INSTALL_DIR}/.actual-install.XXXXXX")" # Complete all copies before activation so an interrupted install cannot mix # archive payload versions. cp -a also preserves bundled-library symlink chains. stage_payload() { local source="$1" local destination="$2" local executable="$3" cp -a "${source}" "${destination}" if [ "${executable}" = "executable" ]; then chmod +x "${destination}" fi } install_macos_menubar_agent() { if [ "${OS}" != "darwin" ] || [ "${ARCH}" != "aarch64" ]; then return 0 fi local label="com.actual.actual-menubar" local agent_dir="${HOME}/Library/LaunchAgents" local log_dir="${HOME}/Library/Logs/Actual" local plist="${agent_dir}/${label}.plist" local gui_target="gui/$(id -u)" if [ ! -x "${ACTUAL_MENUBAR_PATH}" ]; then if command -v launchctl >/dev/null 2>&1; then launchctl bootout "${gui_target}/${label}" >/dev/null 2>&1 || true launchctl bootout "${gui_target}" "${plist}" >/dev/null 2>&1 || true fi rm -f "${plist}" echo "Stable archive did not include Actual menu bar item; skipped menu bar registration." return 0 fi mkdir -p "${agent_dir}" "${log_dir}" cat > "${plist}" << EOF Label ${label} ProgramArguments ${ACTUAL_MENUBAR_PATH} RunAtLoad StandardOutPath ${log_dir}/actual-menubar.log StandardErrorPath ${log_dir}/actual-menubar.err.log EOF if ! command -v launchctl >/dev/null 2>&1; then echo "Warning: launchctl not found; Actual menu bar activation deferred until the next GUI login." >&2 return 0 fi # Match aci-update's package lifecycle: writing the binary/plist is required, # but immediate GUI activation must not prevent CLI installation or sign-in. # RunAtLoad above preserves startup at the next GUI login if activation fails. # launchd can transiently reject bootstrap while the old agent is unloading; # retry its I/O error with the same bounded backoff as the Rust updater. local launchctl_output="" launchctl_status=0 attempt=1 max_attempts=3 launchctl bootout "${gui_target}/${label}" >/dev/null 2>&1 || true while true; do if launchctl_output="$(launchctl bootstrap "${gui_target}" "${plist}" 2>&1)"; then break else launchctl_status=$? fi # A retry cannot create a GUI session on a headless/SSH-only host. if [ "${launchctl_status}" -eq 125 ] || [[ "${launchctl_output}" == *"Domain does not support specified action"* ]] || [[ "${launchctl_output}" == *"Could not find domain for"* ]]; then echo "Warning: no GUI session available; Actual menu bar activation deferred until the next GUI login (status=${launchctl_status}): ${launchctl_output}" >&2 return 0 fi if [ "${attempt}" -ge "${max_attempts}" ] || { [ "${launchctl_status}" -ne 5 ] && [[ "${launchctl_output}" != *"Bootstrap failed: 5"* ]] && [[ "${launchctl_output}" != *"Input/output error"* ]]; }; then echo "Warning: Actual menu bar bootstrap failed; activation deferred until the next GUI login (attempt=${attempt}/${max_attempts}, status=${launchctl_status}): ${launchctl_output}" >&2 return 0 fi echo "Retrying Actual menu bar activation (attempt=${attempt}/${max_attempts}, status=${launchctl_status}): ${launchctl_output}" >&2 launchctl bootout "${gui_target}/${label}" >/dev/null 2>&1 || true case "${attempt}" in 1) sleep 0.25 ;; 2) sleep 0.50 ;; esac attempt=$((attempt + 1)) done if ! launchctl_output="$(launchctl kickstart -k "${gui_target}/${label}" 2>&1)"; then echo "Warning: Actual menu bar kickstart failed; activation deferred until the next GUI login: ${launchctl_output}" >&2 return 0 fi echo "Installed Actual menu bar item." } stage_payload "${TMP_DIR}/actual" "${INSTALL_STAGE_DIR}/actual" executable if [ -f "${TMP_DIR}/actual-daemon" ]; then stage_payload "${TMP_DIR}/actual-daemon" "${INSTALL_STAGE_DIR}/actual-daemon" executable fi if [ -f "${TMP_DIR}/malibu-serve" ]; then stage_payload "${TMP_DIR}/malibu-serve" "${INSTALL_STAGE_DIR}/malibu-serve" executable fi # The e sidecar (linux arm64 GB300 builds, experimental): the daemon finds it # as its sibling, so it installs beside actual-daemon like malibu-serve. if [ -f "${TMP_DIR}/e" ]; then stage_payload "${TMP_DIR}/e" "${INSTALL_STAGE_DIR}/e" executable fi # aci-server is aci-cpp's engine binary; the daemon runs it as a managed # sibling process resolved beside its own executable. Newer archives ship it # at the root next to actual-daemon; older ones do not, so it is never # required and stages only when present. if [ -f "${TMP_DIR}/aci-server" ]; then stage_payload "${TMP_DIR}/aci-server" "${INSTALL_STAGE_DIR}/aci-server" executable fi if [ "${OS}" = "darwin" ] && [ "${ARCH}" = "aarch64" ]; then if [ -f "${TMP_DIR}/actual-menubar" ]; then stage_payload "${TMP_DIR}/actual-menubar" "${INSTALL_STAGE_DIR}/actual-menubar" executable fi fi # Mirror any bundled shared libraries (ROCm tarballs only). cp -a # preserves the symlink chain (libfoo.so -> libfoo.so.0 -> libfoo.so.0.0.X) # so the dynamic loader keeps resolving versioned SONAMEs. while IFS= read -r -d '' lib; do stage_payload "$lib" "${INSTALL_STAGE_DIR}/$(basename "$lib")" library done < <(find "${TMP_DIR}" -maxdepth 1 \( -type f -o -type l \) \ \( -name 'lib*.so*' -o -name 'lib*.dylib*' \) -print0) mv -f "${INSTALL_STAGE_DIR}/actual" "${ACTUAL_BINARY_PATH}" if [ -f "${TMP_DIR}/actual-daemon" ]; then mv -f "${INSTALL_STAGE_DIR}/actual-daemon" "${ACTUAL_DAEMON_PATH}" else rm -f "${ACTUAL_DAEMON_PATH}" echo "Stable archive did not include actual-daemon; installed legacy single-binary client." fi if [ -f "${INSTALL_STAGE_DIR}/malibu-serve" ]; then mv -f "${INSTALL_STAGE_DIR}/malibu-serve" "${INSTALL_DIR}/malibu-serve" fi if [ -f "${INSTALL_STAGE_DIR}/e" ]; then mv -f "${INSTALL_STAGE_DIR}/e" "${INSTALL_DIR}/e" fi if [ -f "${INSTALL_STAGE_DIR}/aci-server" ]; then mv -f "${INSTALL_STAGE_DIR}/aci-server" "${INSTALL_DIR}/aci-server" fi if [ "${OS}" = "darwin" ] && [ "${ARCH}" = "aarch64" ]; then if [ -f "${TMP_DIR}/actual-menubar" ]; then mv -f "${INSTALL_STAGE_DIR}/actual-menubar" "${ACTUAL_MENUBAR_PATH}" else rm -f "${ACTUAL_MENUBAR_PATH}" fi fi while IFS= read -r -d '' lib; do mv -f "$lib" "${INSTALL_DIR}/$(basename "$lib")" done < <(find "${INSTALL_STAGE_DIR}" -maxdepth 1 \( -type f -o -type l \) \ \( -name 'lib*.so*' -o -name 'lib*.dylib*' \) -print0) cat > "${ACTUAL_CMD}" << 'EOF' #!/bin/bash set -uo pipefail SOURCE="${BASH_SOURCE[0]}" while [ -L "${SOURCE}" ]; do SCRIPT_DIR="$(cd "$(dirname "${SOURCE}")" && pwd)" SOURCE="$(readlink "${SOURCE}")" if [[ "${SOURCE}" != /* ]]; then SOURCE="${SCRIPT_DIR}/${SOURCE}" fi done SCRIPT_DIR="$(cd "$(dirname "${SOURCE}")" && pwd)" ACTUAL_BIN="${SCRIPT_DIR}/actual-bin" collect_required_glibc_versions() { grep -o 'GLIBC_[0-9][0-9.]*' "$1" 2>/dev/null | sort -u | paste -sd ',' - | sed 's/,/, /g' } print_prerequisite_hint() { local stderr_file="$1" if grep -q 'libc.so.6: version .*GLIBC_[0-9]' "${stderr_file}" 2>/dev/null; then local required_versions="" required_versions="$(collect_required_glibc_versions "${stderr_file}")" echo "" >&2 echo "Hint: Actual could not start because this Linux system's glibc is older than the downloaded client requires." >&2 if [ -n "${required_versions}" ]; then echo "Missing required glibc versions: ${required_versions}" >&2 fi echo "This usually means the base image or distro is missing a required base software prerequisite." >&2 echo "Use a newer Debian/Ubuntu base image or another supported Linux environment, then retry." >&2 echo "Check your current glibc with: ldd --version" >&2 echo "See https://actual.inc/supported-platforms for supported configurations." >&2 fi } run_actual() { if [ ! -x "${ACTUAL_BIN}" ]; then echo "Error: Actual binary not found at ${ACTUAL_BIN}" >&2 return 1 fi local temp_dir stderr_fifo stderr_log tee_pid status temp_dir="$(mktemp -d)" stderr_fifo="${temp_dir}/stderr.fifo" stderr_log="${temp_dir}/stderr.log" cleanup() { rm -rf "${temp_dir}" } trap cleanup EXIT mkfifo "${stderr_fifo}" tee "${stderr_log}" >&2 < "${stderr_fifo}" & tee_pid=$! "${ACTUAL_BIN}" "$@" 2> "${stderr_fifo}" status=$? wait "${tee_pid}" if [ "${status}" -ne 0 ]; then print_prerequisite_hint "${stderr_log}" fi cleanup trap - EXIT return "${status}" } run_actual "$@" EOF chmod +x "${ACTUAL_CMD}" # Call directly so set -e still catches filesystem failures inside the helper. # An "if ! helper" call disables errexit throughout its body. install_macos_menubar_agent echo "Installed to ${ACTUAL_CMD}" # Create symlink in ~/.local/bin for immediate availability # This is the standard XDG user binary location, often already in PATH LOCAL_BIN="${HOME}/.local/bin" mkdir -p "${LOCAL_BIN}" ln -sf "${ACTUAL_CMD}" "${LOCAL_BIN}/actual" echo "Created symlink at ${LOCAL_BIN}/actual" # Add to PATH permanently if not already there # Returns 0 if PATH was added, 1 if already present add_to_path() { local shell_rc="$1" local is_fish="$2" # Check if config file exists and doesn't already have the PATH entry if [ -f "${shell_rc}" ]; then if grep -q '.actual/bin' "${shell_rc}" 2>/dev/null; then return 1 # Already configured fi fi # Add PATH to config (create file if needed) echo "" >> "${shell_rc}" echo "# Added by Actual Computer installer" >> "${shell_rc}" if [ "${is_fish}" = "1" ]; then echo 'fish_add_path $HOME/.actual/bin' >> "${shell_rc}" else echo 'export PATH="$HOME/.actual/bin:$PATH"' >> "${shell_rc}" fi echo "Added ${INSTALL_DIR} to PATH in ${shell_rc}" return 0 } PATH_UPDATED=0 # Write to all common shell profiles (idempotent — skips if already present) for rc_file in "${HOME}/.profile" "${HOME}/.zshrc" "${HOME}/.bashrc"; do if add_to_path "${rc_file}" "0"; then PATH_UPDATED=1 fi done # macOS: also add to .bash_profile if it exists (login bash) if [ "${OS}" = "darwin" ] && [ -f "${HOME}/.bash_profile" ]; then if add_to_path "${HOME}/.bash_profile" "0"; then PATH_UPDATED=1 fi fi # Fish: add if config directory exists if [ -d "${HOME}/.config/fish" ]; then if add_to_path "${HOME}/.config/fish/config.fish" "1"; then PATH_UPDATED=1 fi fi # Add to current session regardless export PATH="${INSTALL_DIR}:${PATH}" # Verify that the installed launcher can start before continuing. check_install_startup "${ACTUAL_CMD}" # Completion configuration is intentionally opt-in. The installer never edits # completion files or RC files for completion; users preview and approve it. echo "Optional: run 'actual setup-shell' to enable shell completion." install_set_stage signin unexpected_error INSTALL_SIGNIN=incomplete # Authenticate after install (best-effort). # RUST_LOG=off suppresses tracing noise, keeps actual errors visible echo "Logging in..." LOGIN_SUCCEEDED=0 if RUST_LOG=off "${ACTUAL_CMD}" login; then LOGIN_SUCCEEDED=1 INSTALL_SIGNIN=complete else echo "Warning: login failed. Run 'actual login' manually to authenticate." >&2 fi install_set_stage finalize install_io_failed echo "Locking update channel..." if "${ACTUAL_CMD}" update --channel "${CHANNEL}" --check-only >/dev/null 2>&1; then echo "Update channel locked to ${CHANNEL}" else echo "Warning: failed to set update channel via actual update, writing state file" >&2 fi STATE_DIR="${HOME}/.actual/state" STATE_FILE="${STATE_DIR}/active_version.json" mkdir -p "${STATE_DIR}" BUILD_SHA=$("${ACTUAL_CMD}" --build-sha 2>/dev/null || echo "unknown") LAST_SWAP="$(date -u +%Y-%m-%dT%H:%M:%SZ)" if [[ -f "${STATE_FILE}" ]]; then if sed -E -e "s|\"activeVersion\"[[:space:]]*:[[:space:]]*\"[^\"]*\"|\"activeVersion\": \"${BUILD_SHA}\"|" -e "s|\"channel\"[[:space:]]*:[[:space:]]*\"[^\"]*\"|\"channel\": \"${CHANNEL}\"|" -e "s|\"lastSwap\"[[:space:]]*:[[:space:]]*\"[^\"]*\"|\"lastSwap\": \"${LAST_SWAP}\"|" "${STATE_FILE}" > "${STATE_FILE}.tmp"; then mv "${STATE_FILE}.tmp" "${STATE_FILE}" else rm -f "${STATE_FILE}.tmp" fi fi if [[ ! -f "${STATE_FILE}" ]]; then cat > "${STATE_FILE}" << EOF { "activeVersion": "${BUILD_SHA}", "previousVersion": null, "channel": "${CHANNEL}", "lastSwap": "${LAST_SWAP}" } EOF fi install_publish_success echo "" if [ "${LOGIN_SUCCEEDED}" -eq 1 ]; then echo "Actual client installed and sign-in complete." NEXT_COMMAND="actual" else echo "Actual client installed. Sign-in is incomplete." NEXT_COMMAND="actual login" fi # Check if ~/.local/bin is already in PATH (immediate availability) if echo "${PATH}" | grep -q "${HOME}/.local/bin"; then echo "Run '${NEXT_COMMAND}'." elif [ "${PATH_UPDATED}" -eq 1 ]; then echo "" echo "Open a new terminal window or run:" case "${SHELL}" in */fish) echo " source ~/.config/fish/config.fish" ;; */zsh) echo " source ~/.zshrc" ;; *) echo " source ~/.bashrc" ;; esac echo "" echo "Then run '${NEXT_COMMAND}'." else echo "Run '${NEXT_COMMAND}'." fi