Description
What happens
- After running
mdbook init && mdbook serve
and visitinghttp://localhost:3000
inFirefox 75.0
, I am able to visit the website as expected with the following output:
$ mdbook init && mdbook serve
Do you want a .gitignore to be created? (y/n)
y
What title would you like to give the book?
test
2020-04-13 09:29:54 [INFO] (mdbook::book::init): Creating a new book with stub content
All done, no errors...
2020-04-13 09:29:54 [INFO] (mdbook::book): Book building has started
2020-04-13 09:29:54 [INFO] (mdbook::book): Running the html backend
2020-04-13 09:29:54 [INFO] (mdbook::cmd::serve): Serving on: http://localhost:3000
2020-04-13 09:29:54 [INFO] (ws): Listening for new connections on [::1]:3001.
2020-04-13 09:29:54 [INFO] (mdbook::cmd::watch): Listening for changes...
2020-04-13 09:30:03 [INFO] (ws::io): Accepted a new tcp connection from [::1]:51214.
- Upon executing
echo "Hello" >> src/chapter_1.md
in a second terminal, I get the following output as expected.
2020-04-13 09:32:18 [INFO] (mdbook::cmd::serve): Building book...
2020-04-13 09:32:18 [INFO] (mdbook::book): Book building has started
2020-04-13 09:32:18 [INFO] (mdbook::book): Running the html backend
2020-04-13 09:32:19 [INFO] (ws::io): Accepted a new tcp connection from [::1]:51238.
2020-04-13 09:32:53 [INFO] (mdbook::cmd::serve): Files changed: ["/tmp/tmp.EPE3YB7jTQ/src/chapter_1.md"]
- Stop the server
- Move the files into a subfolder without also moving
.gitignore
mkdir mdbook && mv book.toml src mdbook && cd mdbook
mdbook serve
and connect again via Firefox.- Play around with making any changes you desire. Notice it is no longer refreshing or detecting changes.
cp ../.gitignore .
to copy.gitignore
to the mdbook folder.- Play around with making any changes you desire. Notice it IS refreshing or detecting changes.
What is expected
I expect mdbook serve
to always refresh when changes are made regardless of where the .gitignore
file is.
Proposed Resolution
The way I understand it, mdbook serve is looking for a .gitignore file at the base of the mdbook folder structure. This isn't always where .gitignore lives as I usually like to make mdbook a subfolder so I can keep my project alongside its source code. I would like to see mdbook search for the .gitignore file if it doesn't exist in the mdbook base folder.
Temporary Workaround
Keep a copy of .gitignore in both your base git folder and your base mdbook folder.
I will see if this is something I can submit a PR for soon, but I have zero experience with Rust. I am going through The Book, though, so hopefully this would be within my grasp soon. Keep up the fantastic work on this great project!