-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: A bug, incorrect or unintended behaviorCategory: A bug, incorrect or unintended behavior
Description
Problem
When maintaining official rustup
docs, I have noticed that mdbook serve
will work at first but fail immediately after a file update, which can break my workflow quite often:
> mdbook serve ./doc/user-guide --open
2023-10-30 17:17:41 [INFO] (mdbook::book): Book building has started
2023-10-30 17:17:41 [INFO] (mdbook::book): Running the html backend
2023-10-30 17:17:41 [INFO] (mdbook::cmd::serve): Serving on: http://localhost:3000
2023-10-30 17:17:41 [INFO] (mdbook): Opening web browser
2023-10-30 17:17:41 [INFO] (warp::server): Server::run; addr=[::1]:3000
2023-10-30 17:17:41 [INFO] (warp::server): listening on http://[::1]:3000
2023-10-30 17:17:41 [INFO] (mdbook::cmd::watch): Listening for changes...
2023-10-30 17:21:24 [ERROR] (mdbook::cmd::serve): Unable to serve: panicked at 'path is expected to be under the root', /Users/brew/Library/Caches/Homebrew/cargo_cache/registry/src/index.crates.io-6f17d22bba15001f/ignore-0.4.20/src/gitignore.rs:227:9
Steps
git clone https://github.com/rust-lang/rustup.git && cd rustup
mdbook serve ./doc/user-guide --open
- Change anything under
./doc/user-guide
and observe the panic
Possible Solution(s)
I'm not sure what this error message is about, but .matched_path_or_any_parents(path, path.is_dir())
requires path
to be absolute. Maybe at some point down the business logic we need to canonicalize the path so it can appear to "be under the root":
Lines 89 to 99 in 94e0a44
fn filter_ignored_files(ignore: Gitignore, paths: &[PathBuf]) -> Vec<PathBuf> { | |
paths | |
.iter() | |
.filter(|path| { | |
!ignore | |
.matched_path_or_any_parents(path, path.is_dir()) | |
.is_ignore() | |
}) | |
.map(|path| path.to_path_buf()) | |
.collect() | |
} |
Notes
No response
Version
> mdbook --version
mdbook v0.4.35
zakaria-hachem and leonzchang
Metadata
Metadata
Assignees
Labels
C-bugCategory: A bug, incorrect or unintended behaviorCategory: A bug, incorrect or unintended behavior