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 1 commit into
base: master
Choose a base branch
from

Conversation

bfops
Copy link
Collaborator

@bfops bfops commented Apr 29, 2025

Description of Changes

See #2679.

At some point, this code was changed so that current contains an entire path, rather than just the version string itself, so the comparison between ver and current was always failing.

I'm not strongly attached to this particular approach to fixing, if there's a more principled way or a better function I should be using.

API and ABI breaking changes

Not a breaking change.

Expected complexity level and risk

1

Testing

  • It works now!
$ cargo run -pspacetimedb-update -- version list
   Compiling spacetimedb-update v1.1.1 (/home/lead/work/clockwork-localhd/SpacetimeDBPrivate/public/crates/update)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.63s
     Running `target/debug/spacetimedb-update version list`
1.1.1
1.1.0 (current)

I could be convinced to add a smoketest for this.

@bfops bfops requested a review from coolreader18 April 29, 2025 17:12
@bfops bfops linked an issue Apr 29, 2025 that may be closed by this pull request
@coolreader18
Copy link
Collaborator

coolreader18 commented Apr 29, 2025

Oh, whoops. I think the actual root cause is in a different function - this should be a thorough fix. It does mean that the current version will have to be re-set for it to work.

diff --git a/crates/paths/src/cli.rs b/crates/paths/src/cli.rs
index 28d26fb81..f39761c09 100644
--- a/crates/paths/src/cli.rs
+++ b/crates/paths/src/cli.rs
@@ -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

@bfops
Copy link
Collaborator Author

bfops commented Apr 30, 2025

Oh, whoops. I think the actual root cause is in a different function - this should be a thorough fix. It does mean that the current version will have to be re-set for it to work.

diff --git a/crates/paths/src/cli.rs b/crates/paths/src/cli.rs
index 28d26fb81..f39761c09 100644
--- a/crates/paths/src/cli.rs
+++ b/crates/paths/src/cli.rs
@@ -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

Ah okay! thanks for the better fix. Do you have any suggestions for how we fix this for people who already have SpacetimeDB installed? I guess it would just get quietly fixed the next time they upgrade?

@CLAassistant
Copy link

CLAassistant commented May 3, 2025

CLA assistant check
All committers have signed the CLA.

@bfops bfops added the release-any To be landed in any release window label May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-any To be landed in any release window
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spacetime version list does not indicate the current version
3 participants