Skip to content

mdbook serve doesn't see changes if .gitignore isn't in main mdbook folder #1186

Open
@bamhm182

Description

@bamhm182

What happens

  1. After running mdbook init && mdbook serve and visiting http://localhost:3000 in Firefox 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.
  1. 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"]
  1. Stop the server
  2. Move the files into a subfolder without also moving .gitignore
  3. mkdir mdbook && mv book.toml src mdbook && cd mdbook
  4. mdbook serve and connect again via Firefox.
  5. Play around with making any changes you desire. Notice it is no longer refreshing or detecting changes.
  6. cp ../.gitignore . to copy .gitignore to the mdbook folder.
  7. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ignoreArea: gitignore, ignoring filesCommand-serveCommand: serve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions