Skip to content

Improve error when writing mdbook serve from nested folder #3000

@lquenti

Description

@lquenti

Problem

My girlfriend and I are using mdbook for our personal cookbook and it works great! She is non-technical, but I CI-automated the deployment so that once she pushes it automatically updates the deployment. The only issue is as follows:

  • She opens the folder in kate, starts the embedded terminal
  • Tries to mdbook something, with the help of mdbook --help
  • Sees mdbook serve, and gets the following error
klara@zblech:~/Dokumente/data/GitProjekte/rezeptsammlung/src/Klara/Herzhaftes$ mdbook serve
2026-01-03 10:42:02 [ERROR] (mdbook::utils): Error: Couldn't open SUMMARY.md in "/home/klara/Dokumente/data/GitProjekte/rezeptsammlung/src/Klara/Herzhaftes/src" directory
2026-01-03 10:42:02 [ERROR] (mdbook::utils):    Caused By: No such file or directory (os error 2)

This is a confusing error message, as if the reader is not experienced with reading error traces, they think

  • why does it fail, I can see the SUMMARY.md in my text editor tree (as they are just skimming the path)
  • Of course it fails, I don't have this src folder! (As they might not have an understanding how it internally builds the path)

I think this would be easy to improve with a hint

Proposed Solution

on ENOENT error handling (i.e. we are already on the slot path), recursively walk up the path to see whether a parent directory contains a src/SUMMARY.md. If so, print another [INFO] log on whether the user might meant to start it from the parent folder instead.

Notes

No response

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement or feature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions