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

Error when enabling plugin 'macros': 'LiveReloadServer' object has no attribute 'watcher' #86

Closed
edgarcamilocamacho opened this issue Jun 9, 2021 · 15 comments
Labels
bug Something isn't working fixed A fix has been submitted

Comments

@edgarcamilocamacho
Copy link

edgarcamilocamacho commented Jun 9, 2021

Hello.

Using:

  • Linux Mint 20.1 Ulyssa
  • Python 3.8.5 (native)
  • mkdocs 1.2 installed from pip3
  • tested with macros-plugin installed from pip3 (0.5.5) and installed from the github repo (0.5.11)

I am trying to enable the macros plugin. This is my mkdocs.yml file:

site_name: Testing Page

site_url: https://example.com/

theme:
  name: material

plugins:
  - macros

markdown_extensions:
    - pymdownx.highlight:
        use_pygments: true
    - codehilite
    - pymdownx.superfence
...

But I get the following error when building:

INFO     -  Building documentation...
INFO     -  [macros] - Macros arguments: {'module_name': 'main', 'modules': [],
            'include_dir': '', 'include_yaml': [], 'j2_block_start_string': '',
            'j2_block_end_string': '', 'j2_variable_start_string': '', 'j2_variable_end_string':
            '', 'verbose': False}
INFO     -  [macros] - Extra filters (module): ['pretty']
INFO     -  Cleaning site directory
INFO     -  Documentation built in 0.38 seconds
Traceback (most recent call last):
  File "/home/camilo/.local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/camilo/.local/lib/python3.8/site-packages/mkdocs/__main__.py", line 173, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
  File "/home/camilo/.local/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 78, in serve
    server = config['plugins'].run_event('serve', server, config=config, builder=builder)
  File "/home/camilo/.local/lib/python3.8/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/home/camilo/.local/lib/python3.8/site-packages/mkdocs_macros/plugin.py", line 600, in on_serve
    builder = list(server.watcher._tasks.values())[0]["func"]
AttributeError: 'LiveReloadServer' object has no attribute 'watcher'

I get the same error if I use other themes and if I disable extensions.

@github-actions
Copy link

github-actions bot commented Jun 9, 2021

Welcome to this project and thank you!' first issue

@Lucartas
Copy link

Lucartas commented Jun 9, 2021

see this for an explanation: mkdocs/mkdocs#2448
manually patching along the lines of mkdocstrings/mkdocstrings#294 seems to work

@fralau
Copy link
Owner

fralau commented Jun 9, 2021

@Lucartas Thanks! So, that would be an mkdocs issue?

@edgarcamilocamacho If you comment out the macros plugin, do you get the same error?

@ijmitch
Copy link
Contributor

ijmitch commented Jun 9, 2021

There's a description about the effects on on_serve in the mkdocs 1.2 release notes.

( I have tested a minimal mkdocs with and without the macros plugin and it only happens with it enabled. )

@fralau
Copy link
Owner

fralau commented Jun 9, 2021

OK I can see more or less what the problem is. The issue located on that procedure. I guess we will have to rewrite the code so that it is compatible with both 1.2 and the previous ones.

https://github.com/fralau/mkdocs_macros_plugin/blob/6bde2af230f58d6b488d1fea9a24ca182eca483c/mkdocs_macros/plugin.py#L585

@fralau
Copy link
Owner

fralau commented Jun 9, 2021

I issued an emergency fix (4bf847b), version 0.5.12.

Let me know if that works for you (no exception and the watch list works correctly)?

@ijmitch
Copy link
Contributor

ijmitch commented Jun 9, 2021

0.5.12 has stopped the failure for me (macos Catalina, Python 3.9 and Mkdocs 1.2), but I can't really say with certainty if any/all the scenarios for the watch list are working.

@edgarcamilocamacho
Copy link
Author

@fralau 0.5.12 worked perfectly for me. Thanks very much for the incredibly fast response and solution!!

@jaceklaskowski
Copy link

jaceklaskowski commented Jun 10, 2021

How to install the fix (tagged as 0.5.12) using requirements.txt file? Why is 0.5.12 not a release?


Found it! The following works like a charm! 🎉

git+https://github.com/fralau/mkdocs_macros_plugin@v0.5.12#egg=mkdocs-macros-plugin

@ijmitch
Copy link
Contributor

ijmitch commented Jun 10, 2021

@jaceklaskowski yeah... pip install git+https://github.com/fralau/mkdocs_macros_plugin was what worked for me (just letting it pick up the latest).

jan-matthis added a commit to sbi-benchmark/sbi-benchmark.github.io that referenced this issue Jun 17, 2021
@timvink
Copy link
Contributor

timvink commented Jun 17, 2021

Let me know if that works for you (no exception and the watch list works correctly)?

Same error, and your fix works. Thanks!

@edgarcamilocamacho
Copy link
Author

@fralau should I close the issue?

@fralau
Copy link
Owner

fralau commented Jun 19, 2021

In principle yes. But I'd like to confirm that the watch mechanism for included pages (when other directories have been specified) still works.

Anyone?

@fralau
Copy link
Owner

fralau commented Jun 19, 2021

Test passed ✅

(The test directory contains a module test project, where an include directory has been specified, aside of the docone. It works, since startinkg mkdocs serve and modifying include/foo.md triggers a "reload" log message on the console).

If no one has any objections, let's 🚀 and deploy it on pypi?

@fralau
Copy link
Owner

fralau commented Jun 20, 2021

New version 0.5.12 released on pypi.

@fralau fralau closed this as completed Jun 20, 2021
@fralau fralau added bug Something isn't working fixed A fix has been submitted labels Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed A fix has been submitted
Projects
None yet
Development

No branches or pull requests

6 participants