Skip to content

Commit 5140dda

Browse files
committed
util: Account for non-default standalone installation paths in suggested update command
Sets DESTINATION to the installation path we're running under so the new version is installed to the same place, rather than the default path. This muddies the commands but makes them behave better, which is more important. Particularly since soon we'll offer to run these commands automatically for the user.
1 parent 172b072 commit 5140dda

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ development source code and as such may not be routinely kept up to date.
3434
no longer result in a 404 error if `<version>` includes a slash and it is a
3535
valid version specifier. ([#459](https://github.com/nextstrain/cli/pull/459))
3636

37+
* When a standalone installation of Nextstrain CLI suggests a command to run to
38+
update itself, that command now takes into account non-default installation
39+
paths so that the new version is installed to the same place as the current
40+
version.
41+
([#474](https://github.com/nextstrain/cli/pull/474))
42+
3743
# 10.2.1.post1 (1 July 2025)
3844

3945
_See also changes in 10.2.1 which was an unreleased version._

doc/changes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ development source code and as such may not be routinely kept up to date.
3939
no longer result in a 404 error if `<version>` includes a slash and it is a
4040
valid version specifier. ([#459](https://github.com/nextstrain/cli/pull/459))
4141

42+
* When a standalone installation of Nextstrain CLI suggests a command to run to
43+
update itself, that command now takes into account non-default installation
44+
paths so that the new version is installed to the same place as the current
45+
version.
46+
([#474](https://github.com/nextstrain/cli/pull/474))
47+
4248
(v10-2-1-post1)=
4349
## 10.2.1.post1 (1 July 2025)
4450

nextstrain/cli/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,16 @@ def standalone_installation_path() -> Optional[Path]:
235235

236236
def standalone_installer(version: str) -> str:
237237
system = platform.system()
238+
destination = str(standalone_installation_path() or "")
238239

239240
if system == "Linux":
240-
return f"curl -fsSL --proto '=https' https://nextstrain.org/cli/installer/linux | bash -s {shquote(version)}"
241+
return f"curl -fsSL --proto '=https' https://nextstrain.org/cli/installer/linux | DESTINATION={shquote(destination)} bash -s {shquote(version)}"
241242

242243
elif system == "Darwin":
243-
return f"curl -fsSL --proto '=https' https://nextstrain.org/cli/installer/mac | bash -s {shquote(version)}"
244+
return f"curl -fsSL --proto '=https' https://nextstrain.org/cli/installer/mac | DESTINATION={shquote(destination)} bash -s {shquote(version)}"
244245

245246
elif system == "Windows":
246-
return 'Invoke-Expression "& { $(Invoke-RestMethod https://nextstrain.org/cli/installer/windows) } %s"' % shquote(version)
247+
return '$env:DESTINATION=%s; Invoke-Expression "& { $(Invoke-RestMethod https://nextstrain.org/cli/installer/windows) } %s"' % (shquote(destination), shquote(version))
247248

248249
else:
249250
raise RuntimeError(f"unknown system {system!r}")

0 commit comments

Comments
 (0)