Skip to content

Commit adc902e

Browse files
bfopsShubham8287
authored andcommitted
Fix spacetime version list not showing current version (#2680)
Co-authored-by: Zeke Foppa <[email protected]>
1 parent a3af172 commit adc902e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

crates/paths/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl VersionBinDir {
8585
}
8686

8787
fn link_to(&self, path: &Path) -> anyhow::Result<()> {
88-
let rel_path = path.strip_prefix(self).unwrap_or(path);
88+
let rel_path = path.strip_prefix(self.0.parent().unwrap()).unwrap_or(path);
8989
#[cfg(unix)]
9090
{
9191
// remove the link if it already exists

crates/update/src/cli/list.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use spacetimedb_paths::SpacetimePaths;
2+
use std::path::Path;
23

34
/// List installed SpacetimeDB versions.
45
#[derive(clap::Args)]
@@ -10,7 +11,31 @@ pub(super) struct List {
1011

1112
impl List {
1213
pub(super) fn exec(self, paths: &SpacetimePaths) -> anyhow::Result<()> {
13-
let current = paths.cli_bin_dir.current_version()?;
14+
// This `match` part is only here because at one point we had a bug where we were creating
15+
// symlinks that contained the _entire_ path, rather than just the relative path to the
16+
// version directory. It's not strictly necessary, it just fixes our determination of what
17+
// the current version is, for the output of this command.
18+
//
19+
// That symlink bug was fixed in `crates/paths/src/cli.rs` in
20+
// https://github.com/clockworklabs/SpacetimeDB/pull/2680, but this `match` means that this
21+
// output will still be correct for any users that already have one of the bugged symlinks.
22+
//
23+
// Once users upgrade to a version containing #2680, they will have the code that creates
24+
// the fixed symlinks. However, that code won't immediately run, since the upgrade will be
25+
// running from the previous binary they had. So once they upgrade to a version containing
26+
// #2680, _and then_ upgrade once more, their symlinks will be fixed. There's no real
27+
// timeline on when everyone will have done that, but hopefully that helps give a sense of
28+
// how long this code "should" exist for (but it doesn't do any harm afaik).
29+
let current = match paths.cli_bin_dir.current_version()? {
30+
None => None,
31+
Some(path_str) => {
32+
let file_name = Path::new(&path_str)
33+
.file_name()
34+
.and_then(|f| f.to_str())
35+
.ok_or(anyhow::anyhow!("Could not extract current version"))?;
36+
Some(file_name.to_string())
37+
}
38+
};
1439
let versions = if self.all {
1540
let client = super::reqwest_client()?;
1641
super::tokio_block_on(super::install::available_releases(&client))??

0 commit comments

Comments
 (0)