Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra-watch-dirs does not work if cwd is not the root of the book #2113

Closed
naxmefy opened this issue Jul 3, 2023 · 1 comment · Fixed by #2146
Closed

extra-watch-dirs does not work if cwd is not the root of the book #2113

naxmefy opened this issue Jul 3, 2023 · 1 comment · Fixed by #2146
Labels
C-bug Category: A bug, incorrect or unintended behavior Command-serve Command: serve E-Help-wanted Experience: Help Needed

Comments

@naxmefy
Copy link

naxmefy commented Jul 3, 2023

Problem

HINT: cwd = current working directory

command mdbook allows to serve a book from a different cwd like

# current cwd is path/to/repo
# book is path/to/repo/book
# we can call mdbook serve from repo root

mdbook serve book/

same works from an inner folder of the book folder like

# current cwd is path/to/repo/book/assets
# book is path/to/repo/book
# we can call mdbook serve from assets directory

mdbook serve ../book

but if we set configuration extra-watch-dirs - the config is using the cwd - not the root of the book.

[build]
extra-watch-dirs = [
    "assets"
]

Case 1

  1. call mdbook serve from root of the repo
mdbook serve book/

error from output:

2023-07-03 02:54:31 [ERROR] (mdbook::cmd::serve): Unable to serve: panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /Users/naxmefy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-0.4.30/src/cmd/watch.rs:133:39

Case 2

  1. call mdbook serve from assets directory
mdbook serve ../book

error from output:

2023-07-03 02:56:30 [ERROR] (mdbook::cmd::serve): Unable to serve: panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /Users/naxmefy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-0.4.30/src/cmd/watch.rs:133:39

Case 3

  1. call mdbook serve from root of the book
mdbook serve

error from output: No Error


Additional info

If u set configuration to path the resolves the cwd to the target directory like

[build]
extra-watch-dirs = [
    "book/assets"
]

or like

[build]
extra-watch-dirs = [
    "../assets"
]

no error will be produced...but this is not expected.

Steps

  1. create a book
  2. add an extra directory
  3. add the configuration extra-watch-dirs
  4. execute mdbook serve from an different folder than the root of the book

Possible Solution(s)

Just change the loading of extra-watch-dirs from the root of the book like the src configuration and not from the cwd

Notes

How I came to it?

I created a justfile to run some book command from root and got the error

alias b := build
alias bb := book-build
alias bs := book-serve

build:
    cargo build --release
book-build:
    mdbook build book/
book-serve:
    mdbook serve --open book/

Version

v0.4.30
@naxmefy naxmefy added the C-bug Category: A bug, incorrect or unintended behavior label Jul 3, 2023
@naxmefy
Copy link
Author

naxmefy commented Jul 3, 2023

related pr #1884

@ehuss ehuss added E-Help-wanted Experience: Help Needed Command-serve Command: serve labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: A bug, incorrect or unintended behavior Command-serve Command: serve E-Help-wanted Experience: Help Needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants