Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'SearchPlugin' object has no attribute 'is_dirty' #6364

Closed
4 tasks done
vedranmiletic opened this issue Nov 19, 2023 · 7 comments
Closed
4 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@vedranmiletic
Copy link
Contributor

vedranmiletic commented Nov 19, 2023

Context

No response

Bug description

If one enables Material theme after running mkdocs serve, the build will fail with:

% mkdocs serve 
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.18 seconds
INFO    -  [17:53:32] Watching paths for changes: 'docs', 'mkdocs.yml'
INFO    -  [17:53:32] Serving on http://127.0.0.1:8000/
INFO    -  [17:53:36] Browser connected: https://staging.group.miletic.net/
INFO    -  [17:53:47] Detected file changes
INFO    -  Building documentation...
Traceback (most recent call last):
  File "/home/vedranm/software/mkdocs/.venv/lib/python3.9/site-packages/mkdocs/livereload/__init__.py", line 193, in _build_loop
    func()
  File "/home/vedranm/software/mkdocs/.venv/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, live_server=None if is_clean else server, dirty=is_dirty)
  File "/home/vedranm/software/mkdocs/.venv/lib/python3.9/site-packages/mkdocs/commands/build.py", line 354, in build
    config.plugins.on_post_build(config=config)
  File "/home/vedranm/software/mkdocs/.venv/lib/python3.9/site-packages/mkdocs/plugins.py", line 542, in on_post_build
    return self.run_event('post_build', config=config)
  File "/home/vedranm/software/mkdocs/.venv/lib/python3.9/site-packages/mkdocs/plugins.py", line 509, in run_event
    result = method(**kwargs)
  File "/home/vedranm/software/mkdocs/.venv/lib/python3.9/site-packages/material/plugins/search/plugin.py", line 136, in on_post_build
    if self.is_dirty:
AttributeError: 'SearchPlugin' object has no attribute 'is_dirty'
ERROR   -  [17:53:49] An error happened during the rebuild. The server will appear stuck until build errors are resolved.

Related links

Reproduction

9.4.10-searchplugin-is_dirty.zip

Steps to reproduce

  1. mkdocs new mysite
  2. cd mysite
  3. mkdocs serve
  4. Add the following lines to mkdocs.yml while mkdocs serve is running:
    theme:
      name: material
  5. Notice the AttributeError in the terminal.

Browser

No response

Before submitting

@squidfunk squidfunk added the bug Issue reports a bug label Nov 19, 2023
@squidfunk
Copy link
Owner

Thanks for reporting. This is really a minor bug, and can be mitigated by just restarting the server. However, we'll see whether we can fix it.

@vedranmiletic
Copy link
Contributor Author

Thanks, minor indeed, no rush at all. I just randomly encountered it while generating the minimal reproduction for #6365, which is the bug we actually care about much more.

@squidfunk
Copy link
Owner

Fixed in ad83798. That was easy.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Nov 19, 2023
@vedranmiletic
Copy link
Contributor Author

Thank you!

@TimChaubet-I4U
Copy link

My apologies for being inconsistent. What I meant with my post here is we still need to use mkdocs build to get the search plugin activated. I read here that this is fixed. My guess is that you haven't rebuilt the docker image yet.

The docker container runs mkdocs in serve mode, so we need to launch a docker compose exec -it mkdocs sh -c 'mkdocs build' command when we enable a plugin, like search. Just adding it to the yaml file is not enough.
We've added a rebuild command to the startup command of the container, so that restarting it does a build, then serve. So we have a workaround.

From what I understood from this bugreport being fixed, is that mkdocs serve would, from now on, do a build if it's necessary to get a plugin working, when it's added to the yml, but that was perhaps wishful thinking.

@squidfunk
Copy link
Owner

Correct, the fix is still unreleased. If an issue is tagged as resolved, but still open, it is unreleased. We'll release it in the coming days, which will also rebuild the Docker image. Since this is a very minor bug, there's no hurry from our side.

@squidfunk
Copy link
Owner

Released as part of 9.4.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

3 participants