Dashboard › cli › Distillation
c5819886-add0-4f69-b738-d9dc366dd64c["lore_tm_v1_5_Q6i6c1rVhTyxzWP50RJ1yT8FbbrfqohCW965y_4D4","lore_tm_v1_xmVxQaoDVtdoQmy1jdhnYd7pzICOq_bntYdEjRBGFrs","lore_tm_v1_SQgTmHUpTl9Ipl7SBpLSdAjKKmLDJLntOzof5gM4-a0"]
packages/cli/src/lib/binary.ts defines InstallationMethod as "curl" | "brew" | "npm" | "pnpm" | "bun" | "yarn" | "unknown"; parseInstallationMethod(value) lowercases input and rejects values outside the first 6 methods with Invalid method: ${value}. Must be one of: ${VALID_METHODS.join(", ")}.packages/cli/src/lib/binary.ts detects musl Linux via 2 ordered heuristics: 1. existence of /lib/ld-musl-${muslArch}.so.1, where muslArch is x86_64 for x64 and otherwise aarch64; 2. combined stdout/stderr from ldd --version containing "musl" case-insensitively. The result is cached in cachedIsMusl; non-Linux and failed/missing ldd resolve to false.getPlatformBinaryName() returns sentry-<os>-<arch>[-musl][.exe]: OS is darwin, windows, or linux; architecture is arm64 or x64; musl adds -musl; Windows adds .exe.packages/cli/src/lib/binary.ts still hard-codes stable CLI release locations: getBinaryDownloadUrl(version) returns https://github.com/getsentry/cli/releases/download/${version}/${getPlatformBinaryName()}, and GITHUB_RELEASES_URL is https://api.github.com/repos/getsentry/cli/releases.isNightlyVersion(version) identifies nightlies by version.includes("-dev."); compareVersions(a, b) uses semverCompare; isDowngrade(current, target) is true when compareVersions(current, target) === 1.getBinaryPaths(installPath) derives tempPath = ${installPath}.download, oldPath = ${installPath}.old, and lockPath = ${installPath}.lock.determineInstallDir(homeDir, env) uses this exact priority: 1. SENTRY_INSTALL_DIR; 2. ~/.local/bin if it exists and is in PATH; 3. ~/bin if it exists and is in PATH; 4. fallback ~/.sentry/bin.fetchWithUpgradeError(url, init, serviceName) calls customFetch, rethrows AbortError unchanged, maps TLS certificate failures to UpgradeError("network_error", buildTlsErrorDetail(error)), and maps other connection failures to UpgradeError("network_error", \Failed to connect to ${serviceName}: ${msg}`)`.replaceBinarySync(tempPath, installPath) is intentionally synchronous so replacement cannot be interrupted between rename steps. Unix atomically renames temp over the target. Windows first renames the running executable to ${installPath}.old, retries after unlinking an existing .old, tolerates the current binary being absent, and then renames temp into place.cleanupOldBinary(oldPath) fire-and-forgets unlink(oldPath) and ignores errors. It deliberately does not remove .download files because another upgrade may be active; .download cleanup belongs inside the locked upgrade flow.acquireLock(lockPath) first runs mkdirSync(dirname(lockPath), { recursive: true, mode: 0o755 }) outside its lock-contention try/catch, then atomically creates the lock with writeFileSync(lockPath, String(process.pid), { flag: "wx" }).acquireLock(): fresh ~/.sentry/bin, npm-to-nightly migration, or a purged stale SENTRY_INSTALL_DIR could cause ENOENT ... open '.../sentry.lock'. Fix: create the parent directory before lock creation. Keeping mkdirSync outside the try/catch preserves genuine EEXIST, ENOTDIR, and EACCES errors instead of misclassifying them as lock contention; associated issues are CLI-1E1 and CLI-1RV.packages/cli/src/lib/upgrade.ts must always check for Homebrew first because stored installation information may be stale.streamDecompressToFile() in packages/cli/src/lib/upgrade.ts must never wait for or rely on a "drain" event in the relevant failed-stream state, because a stream whose internal buffer is already full may never emit "drain", causing a hang.streamDecompressToFile() must always flush/close the writer. If streaming already failed, that original stream error must take precedence over any writer-ending/cleanup error.packages/cli/src/lib/upgrade.ts contains upgrade-source-sensitive operations including fetchLatestFromGitHub(), fetchLatestFromNpm(), fetchLatestNightlyVersion(), fetchLatestVersion(), nightlyVersionExists(), versionExists(), streamDecompressToFile(), downloadNightlyToPath(), downloadStableToPath(), downloadBinaryToTemp(), tryDeltaUpgrade(), downloadFullBinary(), executeUpgradeHomebrew(), executeUpgradePackageManager(), and executeUpgrade().packages/cli/src/lib/upgrade.ts currently uses NPM_REGISTRY_URL = "https://registry.npmjs.org/sentry", binary verification settings VERIFY_MAX_ATTEMPTS = 6 and VERIFY_BASE_DELAY_MS = 100, and exports OfflineMode = false | "explicit" | "network-fallback".