Skip to content

Commit

Permalink
spawn: versioned links for missing executable too (#4041)
Browse files Browse the repository at this point in the history
Fixing an oversight from #4031: if the user doesn't have any executable
at all on their PATH, don't just blindly tell them to download latest,
it might not even be compatible! Use a versioned link in that case too,
where possible.

```sh
$ which rerun
which: no rerun in (...)

$ RUST_LOG=off cargo r -p code_examples --bin point3d_simple

Error: SpawnViewer(Failed to find Rerun Viewer executable in PATH.

    You can install an appropriate version of the Rerun Viewer via binary releases:
    * Using `cargo`: `cargo binstall --force [email protected]` (see https://github.com/cargo-bins/cargo-binstall)
    * Via direct download from our release assets: https://github.com/rerun-io/rerun/releases/0.10.0/
    * Using `pip`: `pip3 install rerun-sdk==0.10.0` (warning: pip version has slower start times!)

    For more information, refer to our complete install documentation over at:
    https://rerun.io/docs/getting-started/installing-viewer

PATH="...")
```
(This is using my local copy where everything is tagged as if `0.10.0`
was released)
  • Loading branch information
teh-cmc authored Oct 27, 2023
1 parent a346b8a commit c6c50d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions crates/re_build_info/src/crate_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ impl CrateVersion {
}
}

/// True is this version has no metadata at all (rc, dev, alpha, etc).
///
/// I.e. it's an actual, final release.
pub fn is_release(&self) -> bool {
self.meta.is_none()
}

/// Whether or not this build has a `+dev` suffix.
///
/// This is used to identify builds which are not explicit releases,
Expand Down
11 changes: 9 additions & 2 deletions crates/re_sdk/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,15 @@ pub fn spawn(opts: &SpawnOptions) -> Result<(), SpawnError> {
executable_path: executable_path.clone(),
}
} else {
let sdk_version = re_build_info::build_info!().version;
SpawnError::ExecutableNotFoundInPath {
message: MSG_INSTALL_HOW_TO.to_owned(),
// Only recommend a specific Viewer version for non-alpha/rc/dev SDKs.
message: if sdk_version.is_release() {
MSG_INSTALL_HOW_TO_VERSIONED
.replace("__VIEWER_VERSION__", &sdk_version.to_string())
} else {
MSG_INSTALL_HOW_TO.to_owned()
},
executable_name: opts.executable_name.clone(),
search_path: std::env::var("PATH").unwrap_or_else(|_| String::new()),
}
Expand Down Expand Up @@ -219,7 +226,7 @@ pub fn spawn(opts: &SpawnOptions) -> Result<(), SpawnError> {

// Don't recommend installing stuff through registries if the user is running some
// weird version.
if sdk_version.meta.is_none() {
if sdk_version.is_release() {
eprintln!(
"{}",
MSG_INSTALL_HOW_TO_VERSIONED
Expand Down

0 comments on commit c6c50d2

Please sign in to comment.