Skip to content

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.

This PR (following advice by @coolreader18) reverts that behavior so that current just contains a relative dir. However, it also adds some behavior to the list command, so that we gracefully handle the users who already have the symlinks with full paths.

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
@coolreader18
Copy link
Collaborator

coolreader18 commented May 16, 2025

I guess it would just get quietly fixed the next time they upgrade?

Yeah, that's the idea.

@bfops bfops requested review from jdetter and removed request for coolreader18 June 24, 2025 17:58
Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested + working, thanks Zeke 👍

Previous output:

boppy@Johns-Laptop server % spacetime version list
1.1.1-source
1.1.0
1.1.1

new output:

boppy@Johns-Laptop server % spacetime version list
1.1.1-source (current)
1.1.0
1.1.1

@bfops bfops added this pull request to the merge queue Jul 23, 2025
Merged via the queue into master with commit 79137b5 Jul 23, 2025
19 checks passed
Shubham8287 pushed a commit that referenced this pull request Jul 28, 2025
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
@bfops bfops deleted the bfops/fix-current-version branch July 30, 2025 17:19
mamcx pushed a commit that referenced this pull request Aug 26, 2025
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
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

5 participants