Skip to content

Fix spacetime version list not showing current version #2680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/paths/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl VersionBinDir {
}

fn link_to(&self, path: &Path) -> anyhow::Result<()> {
let rel_path = path.strip_prefix(self).unwrap_or(path);
let rel_path = path.strip_prefix(self.0.parent().unwrap()).unwrap_or(path);
#[cfg(unix)]
{
// remove the link if it already exists
Expand Down
27 changes: 26 additions & 1 deletion crates/update/src/cli/list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use spacetimedb_paths::SpacetimePaths;
use std::path::Path;

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

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