From 6fb0bf1fb7f6cae1feb13138879bb8c2fd66f668 Mon Sep 17 00:00:00 2001 From: Marco Inacio Date: Sun, 18 Feb 2024 19:43:00 +0000 Subject: [PATCH] rust: fix windows absolute path resolution --- rust/Cargo.toml | 3 ++- rust/src/download_compile.rs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 2d07f2fa..1a7de615 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -15,9 +15,10 @@ ureq = { version = "2.7", optional = true } tar = { version = "0.4", optional = true } flate2 = { version = "1.0", optional = true } dirs = { version = "5.0", optional = true } +path-absolutize = { version = "3.1", optional = true } [features] -compile-stan-model = ["ureq", "tar", "flate2", "dirs"] +compile-stan-model = ["ureq", "tar", "flate2", "dirs", "path-absolutize"] [build-dependencies] bindgen = "0.69.1" diff --git a/rust/src/download_compile.rs b/rust/src/download_compile.rs index f588fcdb..1156d4e2 100644 --- a/rust/src/download_compile.rs +++ b/rust/src/download_compile.rs @@ -1,5 +1,6 @@ use crate::bs_safe::{BridgeStanError, Result}; use flate2::read::GzDecoder; +use path_absolutize::Absolutize; use std::{ env::temp_dir, fs, @@ -81,7 +82,9 @@ where None => get_bridgestan_src()?, }; - let stan_file = fs::canonicalize(stan_file) + let stan_file = stan_file + .as_ref() + .absolutize() .map_err(|e| BridgeStanError::ModelCompilingFailed(e.to_string()))?; if stan_file.extension().unwrap_or_default() != "stan" {