From 6eb7c25a2ae6a71720f3da6ed4f2188246a9a0f0 Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Mon, 25 Nov 2024 18:47:03 +0100 Subject: [PATCH] fix: do not resolve toolchains from files with --no-net (#145) --- src/elan/config.rs | 6 +++--- src/elan/toolchain.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/elan/config.rs b/src/elan/config.rs index 0f29d65..ec92a0b 100644 --- a/src/elan/config.rs +++ b/src/elan/config.rs @@ -17,7 +17,7 @@ use toolchain::Toolchain; use toml; -use crate::{gc, lookup_toolchain_desc, lookup_unresolved_toolchain_desc, read_toolchain_desc_from_file, UnresolvedToolchainDesc}; +use crate::{gc, lookup_toolchain_desc, lookup_unresolved_toolchain_desc, read_unresolved_toolchain_desc_from_file, UnresolvedToolchainDesc}; #[derive(Debug, Serialize, Clone)] pub enum OverrideReason { @@ -186,10 +186,10 @@ impl Cfg { // Then look for 'lean-toolchain' let toolchain_file = d.join("lean-toolchain"); - if let Ok(desc) = read_toolchain_desc_from_file(self, &toolchain_file) { + if let Ok(desc) = read_unresolved_toolchain_desc_from_file(self, &toolchain_file) { let reason = OverrideReason::ToolchainFile(toolchain_file); gc::add_root(self, d)?; - return Ok(Some((UnresolvedToolchainDesc(desc), reason))); + return Ok(Some((desc, reason))); } // Then look for 'leanpkg.toml' diff --git a/src/elan/toolchain.rs b/src/elan/toolchain.rs index 7d2df8a..1abf0bc 100644 --- a/src/elan/toolchain.rs +++ b/src/elan/toolchain.rs @@ -103,16 +103,20 @@ pub fn lookup_toolchain_desc(cfg: &Cfg, name: &str) -> Result { resolve_toolchain_desc(cfg, &lookup_unresolved_toolchain_desc(cfg, name)?, false) } -pub fn read_toolchain_desc_from_file(cfg: &Cfg, toolchain_file: &Path) -> Result { +pub fn read_unresolved_toolchain_desc_from_file(cfg: &Cfg, toolchain_file: &Path) -> Result { let s = utils::read_file("toolchain file", &toolchain_file)?; if let Some(s) = s.lines().next() { let toolchain_name = s.trim(); - lookup_toolchain_desc(cfg, toolchain_name) + lookup_unresolved_toolchain_desc(cfg, toolchain_name) } else { Err(Error::from(format!("empty toolchain file '{}'", toolchain_file.display()))) } } +pub fn read_toolchain_desc_from_file(cfg: &Cfg, toolchain_file: &Path) -> Result { + resolve_toolchain_desc(cfg, &read_unresolved_toolchain_desc_from_file(cfg, toolchain_file)?, false) +} + impl<'a> Toolchain<'a> { pub fn from(cfg: &'a Cfg, desc: &ToolchainDesc) -> Self { //We need to replace ":" and "/" with "-" in the toolchain name in order to make a name which is a valid