diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs index 6ae23ac841ad..b7985d10db9c 100644 --- a/crates/paths/src/lib.rs +++ b/crates/paths/src/lib.rs @@ -179,6 +179,11 @@ impl AbsPath { self.0.ends_with(&suffix.0) } + /// Equivalent of [`Path::canonicalize`] for `AbsPath`. + pub fn canonicalize(&self) -> Result { + Ok(self.as_ref().canonicalize()?.try_into().unwrap()) + } + // region:delegate-methods // Note that we deliberately don't implement `Deref` here. diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index 2a11f1e8eb82..dc13655c934e 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -150,13 +150,14 @@ impl ProjectWorkspace { ) -> Result { let res = match manifest { ProjectManifest::ProjectJson(project_json) => { + let project_json = project_json.canonicalize()?; let file = fs::read_to_string(&project_json).with_context(|| { format!("Failed to read json file {}", project_json.display()) })?; let data = serde_json::from_str(&file).with_context(|| { format!("Failed to deserialize json file {}", project_json.display()) })?; - let project_location = project_json.parent().to_path_buf(); + let project_location = project_json.parent().unwrap().to_path_buf(); let project_json = ProjectJson::new(&project_location, data); ProjectWorkspace::load_inline( project_json,