Skip to content

Commit

Permalink
fix: do not resolve toolchains from files with --no-net (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha authored Nov 25, 2024
1 parent 99413ca commit 6eb7c25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/elan/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'
Expand Down
8 changes: 6 additions & 2 deletions src/elan/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,20 @@ pub fn lookup_toolchain_desc(cfg: &Cfg, name: &str) -> Result<ToolchainDesc> {
resolve_toolchain_desc(cfg, &lookup_unresolved_toolchain_desc(cfg, name)?, false)
}

pub fn read_toolchain_desc_from_file(cfg: &Cfg, toolchain_file: &Path) -> Result<ToolchainDesc> {
pub fn read_unresolved_toolchain_desc_from_file(cfg: &Cfg, toolchain_file: &Path) -> Result<UnresolvedToolchainDesc> {
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<ToolchainDesc> {
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
Expand Down

0 comments on commit 6eb7c25

Please sign in to comment.