@@ -130,29 +130,28 @@ pub async fn check_version(runtime_path: &Path) -> Result<()> {
130130 runtime_path. display( )
131131 ) ;
132132
133- // should always be a valid semver
134- let my_version = semver:: Version :: from_str ( crate :: VERSION ) . unwrap ( ) ;
133+ let cli_version =
134+ semver:: Version :: from_str ( crate :: VERSION ) . expect ( "crate version to be a valid semver" ) ;
135135
136136 if !runtime_path. try_exists ( ) ? {
137137 bail ! ( "shuttle-runtime binary not found" ) ;
138138 }
139139
140140 // Get runtime version from shuttle-runtime cli
141- // It should print the version and exit immediately, so a timeout is used to not launch servers with non-Shuttle setups
141+ // It should print the version and exit immediately, so a timeout is used
142+ // to not get blocked by blocking programs that don't use the Shuttle runtime.
142143 let stdout = tokio:: time:: timeout ( Duration :: from_millis ( 3000 ) , async move {
143144 tokio:: process:: Command :: new ( runtime_path)
144145 . arg ( "--version" )
145146 . kill_on_drop ( true ) // if the binary does not halt on its own, not killing it will leak child processes
146147 . output ( )
147148 . await
148- . context ( "Failed to run the shuttle-runtime binary to check its version" )
149+ . context ( "Failed to run the binary with shuttle-runtime to check its version" )
149150 . map ( |o| o. stdout )
150151 } )
151152 . await
152- . context ( "Checking the version of shuttle-runtime timed out. Make sure the executable is using #[shuttle-runtime ::main]." ) ??;
153+ . context ( "Checking the version of shuttle-runtime timed out. Make sure the executable is using #[shuttle_runtime ::main]." ) ??;
153154
154- // Parse the version, splitting the version from the name and
155- // and pass it to `to_semver()`.
156155 let runtime_version = semver:: Version :: from_str (
157156 std:: str:: from_utf8 ( & stdout)
158157 . context ( "shuttle-runtime version should be valid utf8" ) ?
@@ -161,14 +160,14 @@ pub async fn check_version(runtime_path: &Path) -> Result<()> {
161160 . 1
162161 . trim ( ) ,
163162 )
164- . context ( "failed to convert user's runtime version to semver" ) ?;
163+ . context ( "failed to convert runtime version to semver" ) ?;
165164
166- if semvers_are_compatible ( & my_version , & runtime_version) {
165+ if semvers_are_compatible ( & cli_version , & runtime_version) {
167166 Ok ( ( ) )
168167 } else {
169168 Err ( VersionMismatchError {
170169 shuttle_runtime : runtime_version,
171- cargo_shuttle : my_version ,
170+ cargo_shuttle : cli_version ,
172171 } )
173172 . context ( "shuttle-runtime and Shuttle CLI have incompatible versions" )
174173 }
0 commit comments