Skip to content

Commit e400a9e

Browse files
hkaltaiclaude
andcommitted
fix(install): alias on the already-installed exit only for a local match
When the matching version comes from another install earlier on PATH, the standalone binary may be older, so its alias would run a different version. Also scope the troubleshooting note to v0.7.1+ curl installs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 06b1962 commit e400a9e

4 files changed

Lines changed: 46 additions & 5 deletions

File tree

‎docs/docs/reference/troubleshooting.md‎

Lines changed: 1 addition & 1 deletion
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`, and installers from before the `altimate-code` alias was added put only that name on PATH. Re-run the installer — it adds `altimate-code` next to `altimate` in `~/.altimate/bin` — or call `altimate` directly:
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):

‎install‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,12 @@ 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.
279-
link_alias "$binary_name"
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+
if [ "$(dirname "$(command -v "$probe")")" = "$INSTALL_DIR" ]; then
282+
link_alias "$binary_name"
283+
fi
280284
exit 0
281285
elif [ -n "$installed_version" ]; then
282286
print_message info "${MUTED}Installed version: ${NC}$installed_version."

‎install.ps1‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,12 @@ if ($probe) {
261261
try { $installedVersion = (& $probe --version 2>$null | Select-Object -First 1).ToString().Trim() } catch {}
262262
if ($installedVersion -eq $specificVersion) {
263263
Write-Muted "Version $specificVersion already installed"
264-
# A standalone install from before the alias existed still gets it.
265-
Install-Alias -Dir $InstallDir
264+
# A standalone install from before the alias existed still gets it, but only when
265+
# the matching binary is the one in $InstallDir, so the alias never runs a different
266+
# version than the one just checked.
267+
if ([IO.Path]::GetDirectoryName($probe) -eq $InstallDir) {
268+
Install-Alias -Dir $InstallDir
269+
}
266270
exit 0
267271
} elseif ($installedVersion) {
268272
Write-Muted "Installed version: $installedVersion."

‎packages/opencode/test/install/install-alias.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,35 @@ describe("install — altimate-code alias, executed", () => {
121121
})
122122
})
123123

124+
testUnlessWindows("the already-installed exit leaves the alias alone when the match is elsewhere on PATH", () => {
125+
withHome((home) => {
126+
const bin = join(home, ".altimate", "bin")
127+
const other = join(home, "other")
128+
const stubs = join(home, "stubs")
129+
mkdirSync(bin, { recursive: true })
130+
mkdirSync(other)
131+
mkdirSync(stubs)
132+
// The matching version comes from another install earlier on PATH; the standalone
133+
// binary is older, so an alias to it would run a different version.
134+
writeFileSync(join(other, "altimate"), "#!/bin/sh\necho 9.9.9\n", { mode: 0o755 })
135+
writeFileSync(join(bin, "altimate"), "#!/bin/sh\necho 1.0.0\n", { mode: 0o755 })
136+
writeFileSync(join(stubs, "curl"), "#!/bin/sh\necho 200\n", { mode: 0o755 })
137+
const res = spawnSync("bash", [INSTALL_SH_PATH, "--version", "9.9.9", "--no-modify-path"], {
138+
encoding: "utf-8",
139+
env: {
140+
...process.env,
141+
HOME: home,
142+
XDG_DATA_HOME: join(home, "data"),
143+
GITHUB_ACTIONS: "",
144+
PATH: `${stubs}:${other}:${bin}:${process.env.PATH}`,
145+
},
146+
})
147+
expect(res.stdout).toContain("already installed")
148+
expect(res.status).toBe(0)
149+
expect(existsSync(join(bin, "altimate-code"))).toBe(false)
150+
})
151+
})
152+
124153
testUnlessWindows("a downloaded release gets the alias", () => {
125154
withHome((home) => {
126155
const stubs = join(home, "stubs")
@@ -211,5 +240,9 @@ describe("install.ps1 — altimate-code alias", () => {
211240
expect(calls[0]).toBeGreaterThan(alreadyInstalled)
212241
expect(calls[0]).toBeLessThan(exitAfter)
213242
expect(calls[1]).toBeGreaterThan(INSTALL_PS1.indexOf("Install-Target -Baseline:$true"))
243+
// The already-installed alias is only for a match found in $InstallDir itself.
244+
const guard = INSTALL_PS1.indexOf("if ([IO.Path]::GetDirectoryName($probe) -eq $InstallDir) {")
245+
expect(guard).toBeGreaterThan(alreadyInstalled)
246+
expect(guard).toBeLessThan(calls[0])
214247
})
215248
})

0 commit comments

Comments
 (0)