From 6245e0f7a11f9bc73722beb1cade6971127a704a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Tue, 6 Aug 2024 13:56:59 -0700 Subject: [PATCH] fix: linkcheck plugin on *nix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Linux and macOS, trying to run with the linkcheck plugin configured would error out with the following error: ``` Error: Unable to resolve the source directory Caused by: No such file or directory (os error 2) × Couldn't build your mdbook at book ├─▶ Rendering failed ╰─▶ The "linkcheck" renderer failed ``` This turns out to have been caused by us passing a relative path to the book directory instead of an absolute path. The relative path was fine for the main rendering process, but not the linkcheck plugin. --- src/site/mdbook.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/site/mdbook.rs b/src/site/mdbook.rs index 547a32f2..2ea85ec8 100644 --- a/src/site/mdbook.rs +++ b/src/site/mdbook.rs @@ -275,8 +275,10 @@ pub fn build_mdbook( /// /// Interesting things only happen when you run `.build()` pub fn load_mdbook(book_dir: &Utf8Path) -> Result { - let md = MDBook::load(book_dir).map_err(|e| OrandaError::MdBookLoad { - path: book_dir.to_string(), + // An absolute path is necessary for plugins such as linkcheck to work. + let path = book_dir.canonicalize_utf8().unwrap_or(book_dir.to_owned()); + let md = MDBook::load(&path).map_err(|e| OrandaError::MdBookLoad { + path: path.to_string(), details: e, })?;