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

insiders build 8.5.6-4.25.2 fails to build a blog #4457

Closed
5 tasks done
hellt opened this issue Oct 5, 2022 · 12 comments
Closed
5 tasks done

insiders build 8.5.6-4.25.2 fails to build a blog #4457

hellt opened this issue Oct 5, 2022 · 12 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@hellt
Copy link
Contributor

hellt commented Oct 5, 2022

Contribution guidelines

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

I built the latest release of mkdocs-insiders and the standalone blog fails to build. Maybe because of the docs_dir setting.

Expected behaviour

Blog builds

Actual behaviour

Blog build fails with the following stack

docker run -it --rm -p 8002:8000 -v $(pwd):/docs ghcr.io/hellt/mkdocs-material-insiders:8.5.6-4.25.2
WARNING  -  Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to
            connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party
            production-ready server instead.
INFO     -  Building documentation...
INFO     -  Cleaning site directory
INFO     -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
              - about.md
              - posts/2017/How to install pyhton3 in Amazon Linux  AMI.md
              - posts/2017/count_lines_in_git_repo.md
              - posts/2017/go_dev_on_mac_linux.md
              - posts/2017/hugo_gitlab_cloudflare.md
              - posts/2017/nginx-uwsgi-flask-alpine.md
              - posts/2017/nokdoc_sentinel_lambda.md
              - posts/2017/sros_rootifier.md
              - posts/2017/vifmove.md
              - posts/2017/virsh_remove_w_xargs.md
              - posts/2017/wait_for_ssh_paramiko.md
              - posts/2017/xrdp_on_ubuntu1604.md
              - posts/2017/yaml_hljs.md
              - posts/2017/yang-explorer-alpine.md
              - posts/2018/aws_csa_certification.md
              - posts/2018/openstack_coa.md
              - posts/2018/s3_multiple_upload.md
              - posts/2018/saturating_with_ftp.md
              - posts/2019/download_ts_streams.md
              - posts/2019/frontend-for-your-restapi.md
              - posts/2019/serverless-gc-functions.md
              - posts/2020/gnmi-arista.md
              - posts/2020/gnmi-map.md
              - posts/2020/gnmic-yang-completions.md
              - posts/2020/gnmic.md
              - posts/2020/netconf-console-docker.md
              - posts/2020/netconf-xml-skeleton.md
              - posts/2020/ngrok_fwd.md
              - posts/2020/nokia-yang-tree.md
              - posts/2020/projectdocs.md
              - posts/2020/remote_capture_eve.md
              - posts/2020/subtree.md
              - posts/2021/containerlab.md
              - posts/2021/git-remove-big-files.md
              - posts/2021/goreleaser-apt-yum.md
              - posts/2021/ovs-free-lacp.md
              - posts/2021/public-srlinux.md
              - posts/2021/scrapli-kubectl.md
              - posts/2021/scrapligo-options.md
              - posts/2021/uksm-patch.md
              - posts/2022/gnmic-openconfig.md
              - posts/2022/guestfish-container.md
              - posts/2022/netrel001.md
              - posts/2022/netrel002.md
              - posts/noshut/2015-06-02-ldp-ordered-label-distribution-control-explained.md
              - posts/noshut/2015-06-14-ospf-neighbors-on-a-point-to-broadcast-network.md
              - posts/noshut/2015-06-22-alcatel-lucent-ospf-configuration-tutorial.md
              - posts/noshut/2015-06-24-alcatel-lucent-configuring-packet-ip-filters.md
              - posts/noshut/2015-08-24-alcatel-lucent-bgp-configuration-tutorial-part-1-basic-ebgp-ibgp.md
              - posts/noshut/2015-09-23-alcatel-lucent-bgp-configuration-tutorial-part-2-bgp-policies-community.md
              - posts/noshut/2015-11-03-basic-l3vpn-bgpmpls-vpn-or-vprn-configuration-alcatel-lucent-juniper.md
              - posts/noshut/2016-04-01-building-web-front-end-for-python-scripts-with-flask.md
              - posts/noshut/2016-11-14-bgp-vpls-explained.md
ERROR    -  Error building page 'index.md': 'pagination' is undefined
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 82, in serve
    builder(config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 75, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 329, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 231, in _build_page
    output = template.render(context)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 4, in top-level template code
    {% extends "main.html" %}
  File "/docs/blog/overrides/main.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/base.html", line 181, in top-level template code
    {% block container %}
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 14, in block 'container'
    {% block pagination %}
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 15, in block 'pagination'
    {% include "partials/pagination.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/partials/pagination.html", line 10, in top-level template code
    pagination({
  File "/usr/local/lib/python3.9/site-packages/jinja2/utils.py", line 83, in from_obj
    if hasattr(obj, "jinja_pass_arg"):
jinja2.exceptions.UndefinedError: 'pagination' is undefined

Steps to reproduce

build a container for the 8.5.6-4.25.2 insiders and try to build a blog with the following settings

Package versions

  • Python: python --version
  • MkDocs: mkdocs --version
  • Material: pip show mkdocs-material | grep -E ^Version

Configuration

site_name: some
docs_dir: blog

nav:
  - Blog:
      - index.md
  - Tags: tags.md


theme:
  name: material
  custom_dir: blog/overrides

  # 404 page
  static_templates:
    - 404.html

  # Don't include MkDocs' JavaScript
  include_search_page: false
  search_index_only: true

  features:
    - navigation.top
    - navigation.instant
    - navigation.tabs
    - search.suggest
    - content.code.annotate
    - toc.follow
    - content.tooltips
    - navigation.indexes

  language: en

# Plugins
plugins:
  - meta
  - blog:
      blog_dir: .
      post_url_date_format: yyyy
      archive: false
      categories: false
  - tags:
      tags_file: tags.md
  - search:
      separator: '[\s\-\_]'
  - minify:
      minify_html: true

System information

  • Operating system: Mac
  • Browser: Chrome
@squidfunk
Copy link
Owner

Thanks for reporting. As always, could you please narrow it down and attach a reproduction?

@squidfunk squidfunk added the needs input Issue needs further input by the reporter label Oct 6, 2022
@hellt
Copy link
Contributor Author

hellt commented Oct 6, 2022

@squidfunk this is as tiny as it gets I think

https://github.com/hellt/netdevops.me/tree/8.5.6-issue

within this bare-bones branch the following is observed

8.5.3 working

❯ docker run -it --rm -p 8002:8000 -v $(pwd):/docs ghcr.io/hellt/mkdocs-material-insiders:8.5.3-insiders-4.24.0
INFO     -  Building documentation...
WARNING  -  Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to
            connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party
            production-ready server instead.
INFO     -  Cleaning site directory
INFO     -  Documentation built in 0.43 seconds
INFO     -  [07:09:54] Watching paths for changes: 'blog', 'mkdocs.yml'
INFO     -  [07:09:54] Serving on http://0.0.0.0:8000/

8.5.6 crashes

❯ docker run -it --rm -p 8002:8000 -v $(pwd):/docs ghcr.io/hellt/mkdocs-material-insiders:8.5.6-4.25.2     
WARNING  -  Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to
            connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party
            production-ready server instead.
INFO     -  Building documentation...
INFO     -  Cleaning site directory
INFO     -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
              - posts/2022/guestfish-container.md
ERROR    -  Error building page 'index.md': 'pagination' is undefined
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 82, in serve
    builder(config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 75, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 329, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 231, in _build_page
    output = template.render(context)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 4, in top-level template code
    {% extends "main.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/main.html", line 4, in top-level template code
    {% extends "base.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/base.html", line 181, in top-level template code
    {% block container %}
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 14, in block 'container'
    {% block pagination %}
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 15, in block 'pagination'
    {% include "partials/pagination.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/partials/pagination.html", line 10, in top-level template code
    pagination({
  File "/usr/local/lib/python3.9/site-packages/jinja2/utils.py", line 83, in from_obj
    if hasattr(obj, "jinja_pass_arg"):
jinja2.exceptions.UndefinedError: 'pagination' is undefined

@squidfunk squidfunk added bug Issue reports a bug and removed needs input Issue needs further input by the reporter labels Oct 7, 2022
@squidfunk
Copy link
Owner

Fixed in squidfunk/mkdocs-material-insiders@2203a968f. The problem came from the refactoring which is related to the latests MkDocs 1.4 compatibility changes, resulting in blog posts not being correctly collected.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Oct 7, 2022
@squidfunk
Copy link
Owner

Released as part of 8.5.6+insiders-4.25.3.

@hellt
Copy link
Contributor Author

hellt commented Oct 9, 2022

it looks like the tag is pointing not the the latest commit as the issue still persists?
https://github.com/squidfunk/mkdocs-material-insiders/commits/master

~/hellt/netdevops.me 8.5.6-issue !2                                                                                                                                                                                                                                                            root@devbox-u20 11:31:02
❯ docker run -it --rm -p 8002:8000 -v $(pwd):/docs ghcr.io/hellt/mkdocs-material-insiders:8.5.6-insiders-4.25.3
WARNING  -  Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server instead.
INFO     -  Building documentation...
INFO     -  Cleaning site directory
ERROR    -  Error building page 'index.md': 'pagination' is undefined
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 82, in serve
    builder(config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 75, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 329, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 231, in _build_page
    output = template.render(context)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 4, in top-level template code
    {% extends "main.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/main.html", line 4, in top-level template code
    {% extends "base.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/base.html", line 181, in top-level template code
    {% block container %}
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 14, in block 'container'
    {% block pagination %}
  File "/usr/local/lib/python3.9/site-packages/material/blog.html", line 15, in block 'pagination'
    {% include "partials/pagination.html" %}
  File "/usr/local/lib/python3.9/site-packages/material/partials/pagination.html", line 10, in top-level template code
    pagination({
  File "/usr/local/lib/python3.9/site-packages/jinja2/utils.py", line 83, in from_obj
    if hasattr(obj, "jinja_pass_arg"):
jinja2.exceptions.UndefinedError: 'pagination' is undefined

@squidfunk
Copy link
Owner

squidfunk commented Oct 9, 2022

Nope, can't reproduce. The fix is definitely included in 8.5.6+insiders-4.25.3 and I'm not seeing this issue anymore. You can try doing a clean installation or use the latest master and check whether the issue persists.

@hellt
Copy link
Contributor Author

hellt commented Oct 9, 2022

I'd appreciate you trying to test it on the minimized example I provided, as it still exhibits the error

git clone --depth 1 --branch 8.5.6-issue https://github.com/hellt/netdevops.me.git
cd netdevops.me
docker run -it --rm  -v $(pwd):/docs ghcr.io/hellt/mkdocs-material-insiders:8.5.6-insiders-4.25.3

the container is built off of the tag from original insiders repo. This output shows that the line you provided above as the fix for that issue is present in this container

docker run -it --rm -v $(pwd):/docs --entrypoint ash ghcr.io/hellt/mkdocs-material-insiders:8.5.6-insiders-4.25.3
/docs # grep -n normpath /usr/local/lib/python3.9/site-packages/material/plugins/blog/plugin.py
123:        self.post_dir = posixpath.normpath(self.post_dir)
148:            path = os.path.normpath(os.path.join(
274:        root = _host(config.nav, posixpath.normpath(path))

I don't use manual installation, instead I rely on the original docker container build pipeline you have in the upstream insiders repo

@squidfunk
Copy link
Owner

Thanks for coming back. I'm not sure why I saw the error gone before, as I've used your example, but it's right that it's still there. It seems that the MkDocs 1.4 refactoring which got rid of all calls to posix.normpath is the root cause of the issue. I've reintroduced posix.normpath in squidfunk/mkdocs-material-insiders@42421ac52 and my testing shows that its gone now. Please test the latest master before I issue the next release.

@squidfunk
Copy link
Owner

The last commit introduced another problem in one substitution. Fixed in squidfunk/mkdocs-material-insiders@494324958.

@hellt
Copy link
Contributor Author

hellt commented Oct 9, 2022

yes, I managed to test https://github.com/squidfunk/mkdocs-material-insiders/commit/42421ac52
and issue was with "Continue reading" href. Container is building for the tip of the master atm

@hellt
Copy link
Contributor Author

hellt commented Oct 9, 2022

@squidfunk tested https://github.com/squidfunk/mkdocs-material-insiders/commit/494324958
all is good now. thanks

@squidfunk
Copy link
Owner

Great. Thanks for testing. Released as 8.5.6+insiders-4.25.4.

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

2 participants