Skip to content

Commit dd5426e

Browse files
committed
fix: handle solc versions with +commit
1 parent 0eec4f0 commit dd5426e

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,17 @@ 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 = if version.pre.is_empty() {
219+
Version::new(version.major, version.minor, version.patch)
220+
} else {
221+
// Preserve version if it is a prerelease.
222+
version.clone()
223+
};
218224
let solc = svm::version_binary(&version.to_string());
219225
if !solc.is_file() {
220226
return Ok(None);
221227
}
222-
Ok(Some(Self::new_with_version(&solc, version.clone())))
228+
Ok(Some(Self::new_with_version(&solc, version)))
223229
}
224230

225231
/// Returns the directory in which [svm](https://github.com/roynalnaruto/svm-rs) stores all versions
@@ -293,18 +299,25 @@ impl Solc {
293299
#[cfg(test)]
294300
crate::take_solc_installer_lock!(_lock);
295301

302+
let version = if version.pre.is_empty() {
303+
Version::new(version.major, version.minor, version.patch)
304+
} else {
305+
// Preserve version if it is a prerelease.
306+
version.clone()
307+
};
308+
296309
trace!("blocking installing solc version \"{}\"", version);
297-
crate::report::solc_installation_start(version);
310+
crate::report::solc_installation_start(&version);
298311
// The async version `svm::install` is used instead of `svm::blocking_install`
299312
// because the underlying `reqwest::blocking::Client` does not behave well
300313
// inside of a Tokio runtime. See: https://github.com/seanmonstar/reqwest/issues/1017
301-
match RuntimeOrHandle::new().block_on(svm::install(version)) {
314+
match RuntimeOrHandle::new().block_on(svm::install(&version)) {
302315
Ok(path) => {
303-
crate::report::solc_installation_success(version);
316+
crate::report::solc_installation_success(&version);
304317
Ok(Self::new_with_version(path, version.clone()))
305318
}
306319
Err(err) => {
307-
crate::report::solc_installation_error(version, &err.to_string());
320+
crate::report::solc_installation_error(&version, &err.to_string());
308321
Err(err)
309322
}
310323
}

0 commit comments

Comments
 (0)