Skip to content

Cryptic error message when override file path does not exist #475

@tleonhardt

Description

@tleonhardt

Context

Suppose in the theme section you specify a custom_dir path which doesn’t actually exist. I was using a mkdocs.yml file for configuration that was copied from a previous project to a new project for which I wanted to use Zensical. And when updating the old file for the new project I forgot to delete the custom_dir option within the theme section so it pointed to a non-existent path.

Previously with MkDocs with the Material Theme I got a very descriptive error message similar to:

ERROR   -  Config value 'theme': The path set in custom_dir ('/home/user/src/project/docs/overrides') does not exist.

Now in Zensical I get a very cryptic error message which is not helpful along the lines of:

thread '<unnamed>' (786354) panicked at crates/zensical/src/config.rs:114:49:
invariant: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/home/user/src/project/.venv/bin/zensical", line 10, in <module>
    sys.exit(cli())
             ~~~^^
  File "/home/user/src/project/.venv/lib/python3.14/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/user/src/project/.venv/lib/python3.14/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
  File "/home/user/src/project/.venv/lib/python3.14/site-packages/click/core.py", line 1873, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/user/src/project/.venv/lib/python3.14/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/src/project/.venv/lib/python3.14/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
  File "/home/user/src/project/.venv/lib/python3.14/site-packages/zensical/main.py", line 83, in execute_build
    build(os.path.abspath(config_file), kwargs.get("clean", False))
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: invariant: Os { code: 2, kind: NotFound, message: "No such file or directory" }

Bug description

If the custom_dir path doesn't exist, there error message is cryptic. I know some path doesn't exist, but I have no idea which one.

Related links

Reproduction

Create a brand new Zensical project, add a custom_dir setting with a non-existent file system path.

Steps to reproduce

  1. Create new Zensical project
  2. Edit configuration file to add custom_dir and set it to a path that doesn't exist
  3. Build documentation

Browser

No response

Before submitting

Metadata

Metadata

Assignees

Labels

bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions