Skip to content

[Insiders] RecursionError when adding Blog plugin #4365

Closed
@davelevine

Description

@davelevine

Contribution guidelines

  • I've read the contribution guidelines and wholeheartedly agree

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
    ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
    ... the documentation does not mention anything about my problem
    ... there are no open or closed issues that are related to my problem

Description

After adding the Blog plugin to a large documentation repo (~500 pages), running mkdocs serve --verbose produces RecursionError: maximum recursion depth exceeded. Creating a copy of this repo and removing ~300 pages of documentation no longer produces the error.

Expected behaviour

Blog plugin should work without error.

Actual behaviour

Running mkdocs serve produces the following:

Traceback (most recent call last):
File "/Users/dave/.pyenv/versions/3.9.13/bin/mkdocs", line 8, in
sys.exit(cli())
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/main.py", line 181, in serve_command
serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 63, in serve
config = builder()
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 58, in builder
build(config, live_server=live_server, dirty=dirty)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/commands/build.py", line 295, in build
env = config['plugins'].run_event(
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/mkdocs/plugins.py", line 102, in run_event
result = method(item, **kwargs)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 408, in on_env
config = deepcopy(config)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 264, in _reconstruct
y = func(*args)
File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 263, in
args = (deepcopy(arg, memo) for arg in args)

The errors beginning at File "/Users/dave/.pyenv/versions/3.9.13/lib/python3.9/copy.py", line 172, in deepcopy y = _reconstruct(x, memo, *rv) run until eventually producing the following error:

RecursionError: maximum recursion depth exceeded

Steps to reproduce

Package versions

  • Python: python --version: Python 3.9.13
  • MkDocs: mkdocs --version: mkdocs, version 1.3.1
  • Material: pip show mkdocs-material | grep -E ^Version: Version: 8.5.0+insiders.4.23.3

Configuration

site_name: My Docs
docs_dir: content
theme: 
  name: material
  custom_dir: theme
  include_search_page: false
  search_index_only: true
  features:
    - navigation.tabs
    - navigation.tabs.sticky
    - navigation.top
    - navigation.tracking
    - navigation.instant
    - navigation.indexes
    - search.suggest
    - search.share
    - announce.dismiss
    - content.code.annotate
    - content.tooltips
plugins:
  # Built-in
  - search:
      separator: '[\s\-,:!=\[\]()"/]+|(?!\b)(?=[A-Z][a-z])|\.(?!\d)|&[lg]t;'
  # Extra
  - git-revision-date-localized:
      type: timeago
      enable_creation_date: true
      exclude:
        - index.md
        - blog/archive/*
        - blog/category/*
  - glightbox:
      touchNavigation: true
      loop: false
      effect: zoom
      width: 100%
      height: auto
      zoomable: true
      draggable: true
  - minify:
      minify_html: true
  - offline:
      enabled: !ENV [OFFLINE, false]
  # Ensure Data Privacy
  - privacy:
      enabled: !ENV [PRIVACY, true]
      externals: bundle
      externals_dir: assets/externals
  - blog
nav:
  - Home: 'index.md'
  - Blog:
    - 'blog/index.md'

System information

  • Operating system: ... macOS 12.5.1
  • Browser: ... Firefox 104.0.2

Activity

squidfunk

squidfunk commented on Sep 14, 2022

@squidfunk
Owner

Thanks for reporting. Please provide a reproducible example and attach it here as a zip.

squidfunk

squidfunk commented on Sep 14, 2022

@squidfunk
Owner

Okay, never mind, other users also reported problems with deepcopy. I've replaced it in squidfunk/mkdocs-material-insiders@88f60a2d4 with a shallow copy, which is sufficient – please try the latest master:

pip install --force git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
added
bugIssue reports a bug
resolvedIssue is resolved, yet unreleased if open
and removed
needs inputIssue needs further input by the reporter
on Sep 14, 2022
davelevine

davelevine commented on Sep 14, 2022

@davelevine
Author

That did the trick! Thanks so much for the extremely fast turnaround, @squidfunk!

squidfunk

squidfunk commented on Sep 14, 2022

@squidfunk
Owner

Released as part of 8.5.0-insiders-4.23.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @squidfunk@davelevine

        Issue actions

          [Insiders] RecursionError when adding Blog plugin · Issue #4365 · squidfunk/mkdocs-material