Skip to content

ConfigurationError: Config file '{paths_to_try[0]}' does not exist when using serve -f - #4053

@ToshY

Description

@ToshY

Problem

Mkdocs serve does not support using file from stdin, unlike mentioned in the documentation. Using serve -f - leads to ConfigurationError: Config file '{paths_to_try[0]}' does not exist when file changes have been detected.

Reproduction

  1. Create a mkdocs.yml
  2. Pass the mkdocs.yml to the serve command: cat mkdocs.yml | mkdocs serve -f -
  3. Make changes to the markdown file
  4. ConfigurationError: Config file '{paths_to_try[0]}' does not exist
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.63 seconds
INFO    -  [17:17:31] Watching paths for changes: 'docs/version/v1'
INFO    -  [17:17:31] Serving on http://0.0.0.0:8000/
INFO    -  [17:17:36] Detected file changes
INFO    -  Building documentation...
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/mkdocs/livereload/__init__.py", line 211, in _build_loop
    self.builder()
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 64, in builder
    config = get_config()
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 43, in get_config
    config = load_config(
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mkdocs/config/base.py", line 360, in load_config
    with _open_config_file(config_file) as fd:
  File "/usr/local/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mkdocs/config/base.py", line 324, in _open_config_file
    raise exceptions.ConfigurationError(f"Config file '{paths_to_try[0]}' does not exist.")
mkdocs.exceptions.ConfigurationError: Config file '<stdin>' does not exist.
ERROR   -  [17:17:36] An error happened during the rebuild. The server will appear stuck until build errors are resolved.

Originally posted in squidfunk/mkdocs-material#8501

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions