Skip to content

Commit f422604

Browse files
hkaltaiclaude
andcommitted
fix(install): expose altimate-code from the standalone installers
curl and PowerShell installs now put altimate-code next to altimate, as npm, Homebrew and AUR do: a relative symlink, or on Windows a .cmd plus a Git Bash shim that stays inert under WSL. Re-running the installer adds it. The uninstall hint names these files. Closes #1563 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 49b5615 commit f422604

11 files changed

Lines changed: 923 additions & 28 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ On Windows, install the same self-contained binary (to `%USERPROFILE%\.altimate\
4242
powershell -c "irm https://www.altimate.sh/install.ps1 | iex"
4343
```
4444

45-
The standalone install drops a single self-contained binary named `altimate`. The npm install exposes both `altimate` and `altimate-code` on PATH; the standalone install only exposes `altimate`. Alpine Linux (musl) and Windows on ARM64 are not currently supported by the standalone binary — use `apk add gcompat` on Alpine, or use WSL on Windows-on-ARM.
45+
The standalone install drops a single self-contained binary named `altimate`, plus an `altimate-code` alias for it — the same two names the npm install exposes. On Windows that alias is an `altimate-code.cmd` shim, which passes its arguments through `cmd.exe` (`%VAR%` expands, unquoted `&` `|` `^` are interpreted), so scripts should call `altimate`. Alpine Linux (musl) and Windows on ARM64 are not currently supported by the standalone binary — use `apk add gcompat` on Alpine, or use WSL on Windows-on-ARM.
4646

4747
For GitHub, [install the Altimate Code App](https://github.com/apps/altimate-code-agent/installations/new)
4848
to select repositories for interactive agent tasks. Automatic dbt pull-request

‎docs/docs/reference/troubleshooting.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: "Fix common Altimate Code installation and runtime issues including
1010

1111
**Symptoms:** `altimate-code: command not found` after running `curl -fsSL https://www.altimate.sh/install | bash`.
1212

13-
As of v0.7.1 the curl-installed binary is named `altimate`, not `altimate-code`. The npm package continues to ship both names. If you scripted against the curl install:
13+
As of v0.7.1 the curl-installed binary is named `altimate`, and curl installs from v0.7.1 until the `altimate-code` alias was added put only that name on PATH (v0.7.0 and earlier installed `altimate-code` under `~/.altimate-code/bin` instead). Re-run the installer — it adds `altimate-code` next to `altimate` in `~/.altimate/bin` — or call `altimate` directly:
1414

1515
```bash
1616
# Before (v0.7.0 and earlier curl install):
@@ -20,8 +20,6 @@ As of v0.7.1 the curl-installed binary is named `altimate`, not `altimate-code`.
2020
~/.altimate/bin/altimate run "..."
2121
```
2222

23-
Or stay on the `altimate-code` name by installing via npm: `npm install -g altimate-code`.
24-
2523
### `Cannot find module '@altimateai/altimate-code-core'`
2624

2725
**Symptoms:** Binary crashes on first run with the above error (curl-installed v0.7.0 and earlier).

‎docs/docs/reference/windows-wsl.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ powershell -c "irm https://www.altimate.sh/install.ps1 | iex"
1919
```
2020

2121
This downloads `altimate.exe` to `%USERPROFILE%\.altimate\bin` and adds that
22-
directory to your user PATH (open a new terminal afterwards). The installer
22+
directory to your user PATH (open a new terminal afterwards). It also writes an
23+
`altimate-code` alias there: `altimate-code.cmd` for cmd.exe and PowerShell, and
24+
an extensionless shim for Git Bash. Inside WSL, install the Linux build with the
25+
curl one-liner; the Windows shim refuses to run there. The installer
2326
auto-detects AVX2 support and falls back to the baseline build on older CPUs.
2427

2528
Options (pass via a script block):

‎install‎

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ check_version() {
275275
# treat an empty==empty as "already installed" — fall through and reinstall.
276276
if [ -n "$specific_version" ] && [[ "$installed_version" == "$specific_version" ]]; then
277277
print_message info "${MUTED}Version ${NC}$specific_version${MUTED} already installed${NC}"
278+
# A standalone install from before the alias existed still gets it, but only
279+
# when the matching binary is the one in INSTALL_DIR, so the alias never runs a
280+
# different version than the one just checked.
281+
# -ef compares the directories themselves, so a PATH entry spelled differently
282+
# (a symlinked HOME, a trailing slash) still matches.
283+
if [ "$(dirname "$(command -v "$probe")")" -ef "$INSTALL_DIR" ]; then
284+
link_alias "$binary_name"
285+
fi
278286
exit 0
279287
elif [ -n "$installed_version" ]; then
280288
print_message info "${MUTED}Installed version: ${NC}$installed_version."
@@ -453,18 +461,77 @@ download_and_install() {
453461
mv "$tmp_dir/$binary_name" "${INSTALL_DIR}/$binary_name"
454462
chmod 755 "${INSTALL_DIR}/$binary_name"
455463

456-
# If the previous install dropped `altimate-code` here (pre-v0.7.1 curl
457-
# install), remove it so users don't end up running a stale binary by
458-
# name. The npm/Homebrew/AUR paths still expose both names; only the
459-
# standalone $INSTALL_DIR has the rename collapse.
460-
if [ "$os" != "windows" ] && [ -f "${INSTALL_DIR}/altimate-code" ]; then
461-
rm -f "${INSTALL_DIR}/altimate-code"
462-
print_message info "${MUTED}Removed stale ${NC}altimate-code${MUTED} from ${NC}$INSTALL_DIR${MUTED} (renamed to altimate in v0.7.1)${NC}"
463-
fi
464+
link_alias "$binary_name"
464465

465466
rm -rf "$tmp_dir"
466467
}
467468

469+
# Expose `altimate-code` next to the installed binary, matching npm, Homebrew and
470+
# AUR, which all ship both names. A relative symlink keeps following the binary
471+
# across upgrades. `ln -sfn` also replaces a pre-v0.7.1 standalone `altimate-code`
472+
# binary, so that name can never run a stale build, and replaces a link to a
473+
# directory instead of writing into that directory. Under Git Bash, MSYS and
474+
# Cygwin, where `ln -s` usually makes a full copy, the shims install.ps1 writes
475+
# are written instead, so both Windows installers leave the same layout.
476+
link_alias() {
477+
local target="$1"
478+
local alias_name
479+
case "$target" in
480+
altimate) alias_name="altimate-code" ;;
481+
altimate.exe) alias_name="altimate-code.exe" ;;
482+
*) return 0 ;;
483+
esac
484+
[ -f "${INSTALL_DIR}/$target" ] || return 0
485+
486+
case "$(uname -s)" in
487+
MINGW*|MSYS*|CYGWIN*)
488+
[ "$target" = "altimate.exe" ] && write_windows_shims
489+
return 0
490+
;;
491+
esac
492+
493+
if [ -d "${INSTALL_DIR}/$alias_name" ] && [ ! -L "${INSTALL_DIR}/$alias_name" ]; then
494+
print_message warning "${MUTED}Skipped the ${NC}$alias_name${MUTED} alias: ${NC}${INSTALL_DIR}/$alias_name${MUTED} is a directory${NC}"
495+
return 0
496+
fi
497+
498+
if ! (cd "$INSTALL_DIR" && ln -sfn "$target" "$alias_name"); then
499+
print_message warning "${MUTED}Could not create the ${NC}$alias_name${MUTED} alias in ${NC}$INSTALL_DIR"
500+
fi
501+
}
502+
503+
# The two shims Install-Alias in install.ps1 writes, byte for byte; keep both
504+
# copies in step. The .cmd first, and a stray altimate-code.exe (which PATHEXT
505+
# would put in front of it, and which older Git Bash installs left as a full copy)
506+
# goes only once it exists. The sh shim only runs under Git Bash, MSYS or Cygwin:
507+
# WSL also sees this directory on PATH, and there it must not pass for a Linux
508+
# install of the same version.
509+
write_windows_shims() {
510+
local exe="${INSTALL_DIR}/altimate-code.exe"
511+
rm -f "$exe.old" 2>/dev/null || true
512+
write_shim altimate-code.cmd '@echo off\r\n"%%~dp0altimate.exe" %%*\r\nexit /b %%ERRORLEVEL%%\r\n' || return 0
513+
if [ -f "$exe" ] || [ -L "$exe" ]; then
514+
rm -f "$exe" 2>/dev/null || mv -f "$exe" "$exe.old" 2>/dev/null ||
515+
print_message warning "${MUTED}Could not remove ${NC}$exe${MUTED}, which shadows the altimate-code.cmd alias${NC}"
516+
fi
517+
write_shim altimate-code '#!/bin/sh\ncase "$(uname -s)" in\n MINGW*|MSYS*|CYGWIN*) exec "$(dirname "$0")/altimate.exe" "$@" ;;\nesac\necho "altimate-code: this is the Windows build; it runs only from Git Bash, MSYS or Cygwin" >&2\nexit 127\n' || return 0
518+
}
519+
520+
# Writes printf format $2 to $INSTALL_DIR/$1 as an executable file (Cygwin keeps
521+
# POSIX modes, so the sh shim needs the bit), replacing a file or link there
522+
# instead of writing through it. A real directory is left alone.
523+
write_shim() {
524+
local path="${INSTALL_DIR}/$1"
525+
if [ -d "$path" ] && [ ! -L "$path" ]; then
526+
print_message warning "${MUTED}Skipped the ${NC}$1${MUTED} alias: ${NC}$path${MUTED} is a directory${NC}"
527+
return 1
528+
fi
529+
if ! { rm -f "$path" && printf "$2" > "$path" && chmod 755 "$path"; } 2>/dev/null; then
530+
print_message warning "${MUTED}Could not create the ${NC}$1${MUTED} alias in ${NC}$INSTALL_DIR"
531+
return 1
532+
fi
533+
}
534+
468535
install_from_binary() {
469536
# --binary may point to either altimate or altimate.exe; preserve the
470537
# caller's basename so the installed file matches what was supplied.
@@ -479,12 +546,14 @@ install_from_binary() {
479546
if [ -f "$dest_path" ] && [ "$binary_path" -ef "$dest_path" ]; then
480547
print_message info "${MUTED}Source and destination are the same file — nothing to do: ${NC}$dest_path"
481548
chmod 755 "$dest_path"
549+
link_alias "$dest_name"
482550
return 0
483551
fi
484552

485553
print_message info "\n${MUTED}Installing ${NC}$dest_name ${MUTED}from: ${NC}$binary_path"
486554
cp "$binary_path" "$dest_path"
487555
chmod 755 "$dest_path"
556+
link_alias "$dest_name"
488557
}
489558

490559
# Write the same post-install marker that npm's postinstall.mjs writes, so the

‎install.ps1‎

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,85 @@ $InstalledBinary = Join-Path $InstallDir $BinaryName
4040
function Write-Muted($msg) { Write-Host $msg -ForegroundColor DarkGray }
4141
function Write-Err($msg) { Write-Host "error: $msg" -ForegroundColor Red }
4242

43+
# Expose `altimate-code` next to altimate.exe, matching npm, Homebrew and AUR,
44+
# which all ship both names. Shims instead of a copy or link: they follow the
45+
# binary across upgrades (which rename the running exe aside) and need no symlink
46+
# privilege. cmd.exe and PowerShell resolve the .cmd; Git Bash and other MSYS
47+
# shells only resolve the extensionless script. The bash installer writes the
48+
# same two shims under Git Bash (write_windows_shims); keep both copies in step.
49+
# npm also writes a .ps1 shim, left out here because an execution policy that
50+
# blocks scripts would break the name. Like every .cmd shim, the .cmd hands its
51+
# arguments to cmd.exe, which expands %VAR% and interprets unquoted & | < > ^;
52+
# scripts should call `altimate`. A stray altimate-code.exe would win over the
53+
# .cmd through PATHEXT order and could run a stale build, so it is moved out of
54+
# the way.
55+
#
56+
# Best-effort: a failure here warns and never aborts the install.
57+
function Install-Alias {
58+
param([string]$Dir)
59+
60+
try {
61+
if (-not (Test-Path -LiteralPath ([IO.Path]::Combine($Dir, "altimate.exe")) -PathType Leaf)) { return }
62+
63+
$shadowingExe = [IO.Path]::Combine($Dir, "altimate-code.exe")
64+
Remove-Item -LiteralPath "$shadowingExe.old" -Force -ErrorAction SilentlyContinue
65+
66+
# Replaces an existing file or link instead of writing through it, so a link at the
67+
# shim's path can never overwrite the file it points to; GetAttributes does not follow
68+
# links, so a dangling one is caught too. The old entry is deleted before the write,
69+
# so a failed write leaves no shim of that name. A real directory is left alone and
70+
# the write throws into the catch.
71+
$writeShim = {
72+
param([string]$Name, [string]$Text)
73+
$path = [IO.Path]::Combine($Dir, $Name)
74+
$attrs = $null
75+
try { $attrs = [IO.File]::GetAttributes($path) } catch {}
76+
if ($null -ne $attrs) {
77+
$isDir = [bool]($attrs -band [IO.FileAttributes]::Directory)
78+
if ($isDir -and ($attrs -band [IO.FileAttributes]::ReparsePoint)) { [IO.Directory]::Delete($path) }
79+
elseif (-not $isDir) { [IO.File]::Delete($path) }
80+
}
81+
[IO.File]::WriteAllText($path, $Text, [Text.Encoding]::ASCII)
82+
}
83+
84+
# The .cmd first, and the exe that would shadow it goes only once it exists: if it
85+
# cannot be written, an existing altimate-code.exe stays usable. `altimate-code
86+
# upgrade` run through the .cmd rewrites it while cmd.exe is still reading it by byte
87+
# offset, which is safe only while its content stays byte-identical.
88+
& $writeShim "altimate-code.cmd" "@echo off`r`n`"%~dp0altimate.exe`" %*`r`nexit /b %ERRORLEVEL%`r`n"
89+
90+
if (Test-Path -LiteralPath $shadowingExe -PathType Leaf) {
91+
try { Remove-Item -LiteralPath $shadowingExe -Force } catch {
92+
Remove-Item -LiteralPath "$shadowingExe.old" -Force -ErrorAction SilentlyContinue
93+
Move-Item -LiteralPath $shadowingExe -Destination "$shadowingExe.old" -Force
94+
}
95+
}
96+
97+
# Only under Git Bash, MSYS or Cygwin: WSL also sees this directory on PATH, and there
98+
# the shim must not pass for a Linux install of the same version.
99+
& $writeShim "altimate-code" ((@(
100+
'#!/bin/sh'
101+
'case "$(uname -s)" in'
102+
' MINGW*|MSYS*|CYGWIN*) exec "$(dirname "$0")/altimate.exe" "$@" ;;'
103+
'esac'
104+
'echo "altimate-code: this is the Windows build; it runs only from Git Bash, MSYS or Cygwin" >&2'
105+
'exit 127'
106+
) -join "`n") + "`n")
107+
} catch {
108+
Write-Muted "Could not create the altimate-code alias in ${Dir}: $($_.Exception.Message)"
109+
}
110+
}
111+
112+
# Whether $Path names a file directly in $Dir. Compared as full paths, ignoring case and
113+
# a trailing separator, since a PATH entry can spell the directory differently.
114+
function Test-PathInDir {
115+
param([string]$Path, [string]$Dir)
116+
117+
$separators = [char[]]@('\', '/')
118+
$parent = [IO.Path]::GetDirectoryName([IO.Path]::GetFullPath($Path)).TrimEnd($separators)
119+
return $parent -eq [IO.Path]::GetFullPath($Dir).TrimEnd($separators)
120+
}
121+
43122
function Show-Usage {
44123
Write-Host @"
45124
Altimate Code Installer (Windows)
@@ -198,8 +277,8 @@ if ([string]::IsNullOrWhiteSpace($Version)) {
198277
# ---------------------------------------------------------------------------
199278
# Skip if the requested version is already installed
200279
# ---------------------------------------------------------------------------
201-
# Probe both names: the standalone install ships `altimate`, but an npm install
202-
# also exposes the `altimate-code` alias.
280+
# Probe both names: either can be the only one on PATH (a standalone install from
281+
# before the `altimate-code` shims, or a package manager that exposes one name).
203282
$probe = $null
204283
foreach ($name in @("altimate", "altimate-code")) {
205284
$cmd = Get-Command $name -ErrorAction SilentlyContinue
@@ -210,6 +289,12 @@ if ($probe) {
210289
try { $installedVersion = (& $probe --version 2>$null | Select-Object -First 1).ToString().Trim() } catch {}
211290
if ($installedVersion -eq $specificVersion) {
212291
Write-Muted "Version $specificVersion already installed"
292+
# A standalone install from before the alias existed still gets it, but only when
293+
# the matching binary is the one in $InstallDir, so the alias never runs a different
294+
# version than the one just checked.
295+
if (Test-PathInDir -Path $probe -Dir $InstallDir) {
296+
Install-Alias -Dir $InstallDir
297+
}
213298
exit 0
214299
} elseif ($installedVersion) {
215300
Write-Muted "Installed version: $installedVersion."
@@ -304,6 +389,8 @@ if (-not $needsBaseline) {
304389
}
305390
}
306391

392+
Install-Alias -Dir $InstallDir
393+
307394
# ---------------------------------------------------------------------------
308395
# Post-install marker (install telemetry)
309396
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)