Skip to content

Commit 8f1c61c

Browse files
authored
fix: preserve pre release version (#340)
- preserve version, including prerelease if any, and pass to svm-rs - needed in `find_svm_installed_version` to identify local binary and avoid installing it on each run - svm-rs logic to deal with looking up and installing prereleases in alloy-rs/svm-rs#176
1 parent c0c2f4b commit 8f1c61c

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

crates/compilers/src/compilers/solc/compiler.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,11 @@ impl Solc {
215215
#[instrument(skip_all)]
216216
#[cfg(feature = "svm-solc")]
217217
pub fn find_svm_installed_version(version: &Version) -> Result<Option<Self>> {
218-
let version = Version::new(version.major, version.minor, version.patch);
219218
let solc = svm::version_binary(&version.to_string());
220219
if !solc.is_file() {
221220
return Ok(None);
222221
}
223-
Ok(Some(Self::new_with_version(&solc, version)))
222+
Ok(Some(Self::new_with_version(&solc, version.clone())))
224223
}
225224

226225
/// Returns the directory in which [svm](https://github.com/roynalnaruto/svm-rs) stores all versions
@@ -294,25 +293,18 @@ impl Solc {
294293
#[cfg(test)]
295294
crate::take_solc_installer_lock!(_lock);
296295

297-
let version = if version.pre.is_empty() {
298-
Version::new(version.major, version.minor, version.patch)
299-
} else {
300-
// Preserve version if it is a prerelease.
301-
version.clone()
302-
};
303-
304296
trace!("blocking installing solc version \"{}\"", version);
305-
crate::report::solc_installation_start(&version);
297+
crate::report::solc_installation_start(version);
306298
// The async version `svm::install` is used instead of `svm::blocking_install`
307299
// because the underlying `reqwest::blocking::Client` does not behave well
308300
// inside of a Tokio runtime. See: https://github.com/seanmonstar/reqwest/issues/1017
309-
match RuntimeOrHandle::new().block_on(svm::install(&version)) {
301+
match RuntimeOrHandle::new().block_on(svm::install(version)) {
310302
Ok(path) => {
311-
crate::report::solc_installation_success(&version);
303+
crate::report::solc_installation_success(version);
312304
Ok(Self::new_with_version(path, version.clone()))
313305
}
314306
Err(err) => {
315-
crate::report::solc_installation_error(&version, &err.to_string());
307+
crate::report::solc_installation_error(version, &err.to_string());
316308
Err(err)
317309
}
318310
}

0 commit comments

Comments
 (0)