Skip to content

Commit

Permalink
fix: linkcheck plugin on *nix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mistydemeo committed Aug 6, 2024
1 parent 0044504 commit 6245e0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/site/mdbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ pub fn build_mdbook(
///
/// Interesting things only happen when you run `.build()`
pub fn load_mdbook(book_dir: &Utf8Path) -> Result<MDBook> {
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,
})?;

Expand Down

0 comments on commit 6245e0f

Please sign in to comment.