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

jinja2 3.1.0 breaks mkdocs #1631

Closed
Orbiter opened this issue Mar 24, 2022 · 2 comments
Closed

jinja2 3.1.0 breaks mkdocs #1631

Orbiter opened this issue Mar 24, 2022 · 2 comments

Comments

@Orbiter
Copy link

Orbiter commented Mar 24, 2022

since the jinja2 3.1.0 release mkdocs does not work any more:

admin@host ui % pip install jinja2==3.1.0
Collecting jinja2==3.1.0
  Using cached Jinja2-3.1.0-py3-none-any.whl (132 kB)
Installing collected packages: jinja2
  Attempting uninstall: jinja2
    Found existing installation: Jinja2 3.0.0
    Uninstalling Jinja2-3.0.0:
      Successfully uninstalled Jinja2-3.0.0
Successfully installed jinja2-3.1.0
admin@host ui % mkdocs build
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 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 187, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/base.py", line 216, in load_config
    from mkdocs.config.defaults import get_schema
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/defaults.py", line 1, in <module>
    from mkdocs.config import config_options
  File "/usr/local/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 8, in <module>
    from mkdocs import utils, theme, plugins
  File "/usr/local/lib/python3.9/site-packages/mkdocs/theme.py", line 6, in <module>
    from mkdocs.utils import filters
  File "/usr/local/lib/python3.9/site-packages/mkdocs/utils/filters.py", line 13, in <module>
    @jinja2.contextfilter
AttributeError: module 'jinja2' has no attribute 'contextfilter'

However, if I install jinja2 3.0.0:

admin@host ui % pip install jinja2==3.0.0
Collecting jinja2==3.0.0
  Using cached Jinja2-3.0.0-py3-none-any.whl (133 kB)
Requirement already satisfied: MarkupSafe>=2.0.0rc2 in /usr/local/lib/python3.9/site-packages (from jinja2==3.0.0) (2.1.1)
Installing collected packages: jinja2
  Attempting uninstall: jinja2
    Found existing installation: Jinja2 3.1.0
    Uninstalling Jinja2-3.1.0:
      Successfully uninstalled Jinja2-3.1.0
Successfully installed jinja2-3.0.0
admin@host ui % mkdocs build
INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /Users/admin/git/searchlab/ui/site
INFO     -  Documentation built in 0.33 seconds
  • mkdocs can be patched by explicitly installing jinja2 3.0.0.
  • maybe this is not a jinja2 bug, but a mkdocs bug; however, maybe it was unwanted that client applications break.

cross-reference bug in mkdocs: mkdocs/mkdocs#2799

@davidism
Copy link
Member

That was previously deprecated, then removed, called out both times in the changelog. Use a tool like pip-tools to pin your dependencies and control when you get updates. Mkdocs can run their tests with deprecation warnings treated as errors so that they get notified of these types of changes early.

@Orbiter
Copy link
Author

Orbiter commented Mar 24, 2022

ok, thanks!

rgacogne added a commit to rgacogne/pdns that referenced this issue Mar 25, 2022
Jinja2 3.1.0 removed deprecated code that is still used by sphinx
1.8.x, and it looks like our custom sphinx extensions are not working
with more recent versions of sphinx..

See:
- pallets/jinja#1631
- readthedocs/readthedocs.org#9037

and

- PowerDNS#7712

The exact error is:
```
Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/dnsdist/pdns/dnsdistdist/.venv/lib/python3.7/site-packages/jinja2/__init__.py))
```
Habbie pushed a commit to Habbie/pdns that referenced this issue Mar 25, 2022
Jinja2 3.1.0 removed deprecated code that is still used by sphinx
1.8.x, and it looks like our custom sphinx extensions are not working
with more recent versions of sphinx..

See:
- pallets/jinja#1631
- readthedocs/readthedocs.org#9037

and

- PowerDNS#7712

The exact error is:
```
Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/dnsdist/pdns/dnsdistdist/.venv/lib/python3.7/site-packages/jinja2/__init__.py))
```

(cherry picked from commit 92ad297)
Habbie pushed a commit to Habbie/pdns that referenced this issue Mar 25, 2022
Jinja2 3.1.0 removed deprecated code that is still used by sphinx
1.8.x, and it looks like our custom sphinx extensions are not working
with more recent versions of sphinx..

See:
- pallets/jinja#1631
- readthedocs/readthedocs.org#9037

and

- PowerDNS#7712

The exact error is:
```
Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/dnsdist/pdns/dnsdistdist/.venv/lib/python3.7/site-packages/jinja2/__init__.py))
```

(cherry picked from commit 92ad297)
Habbie pushed a commit to Habbie/pdns that referenced this issue Mar 25, 2022
Jinja2 3.1.0 removed deprecated code that is still used by sphinx
1.8.x, and it looks like our custom sphinx extensions are not working
with more recent versions of sphinx..

See:
- pallets/jinja#1631
- readthedocs/readthedocs.org#9037

and

- PowerDNS#7712

The exact error is:
```
Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/dnsdist/pdns/dnsdistdist/.venv/lib/python3.7/site-packages/jinja2/__init__.py))
```

(cherry picked from commit 92ad297)
Habbie pushed a commit to Habbie/pdns that referenced this issue Mar 25, 2022
Jinja2 3.1.0 removed deprecated code that is still used by sphinx
1.8.x, and it looks like our custom sphinx extensions are not working
with more recent versions of sphinx..

See:
- pallets/jinja#1631
- readthedocs/readthedocs.org#9037

and

- PowerDNS#7712

The exact error is:
```
Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/dnsdist/pdns/dnsdistdist/.venv/lib/python3.7/site-packages/jinja2/__init__.py))
```

(cherry picked from commit 92ad297)
Habbie pushed a commit to Habbie/pdns that referenced this issue Mar 25, 2022
Jinja2 3.1.0 removed deprecated code that is still used by sphinx
1.8.x, and it looks like our custom sphinx extensions are not working
with more recent versions of sphinx..

See:
- pallets/jinja#1631
- readthedocs/readthedocs.org#9037

and

- PowerDNS#7712

The exact error is:
```
Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/dnsdist/pdns/dnsdistdist/.venv/lib/python3.7/site-packages/jinja2/__init__.py))
```

(cherry picked from commit 92ad297)
Habbie pushed a commit to Habbie/pdns that referenced this issue Mar 25, 2022
Jinja2 3.1.0 removed deprecated code that is still used by sphinx
1.8.x, and it looks like our custom sphinx extensions are not working
with more recent versions of sphinx..

See:
- pallets/jinja#1631
- readthedocs/readthedocs.org#9037

and

- PowerDNS#7712

The exact error is:
```
Extension error:
Could not import extension sphinx.builders.latex (exception: cannot import name 'contextfunction' from 'jinja2' (/dnsdist/pdns/dnsdistdist/.venv/lib/python3.7/site-packages/jinja2/__init__.py))
```

(cherry picked from commit 92ad297)
vitek-rostislav added a commit to shopsys/shopsys that referenced this issue Mar 30, 2022
vitek-rostislav added a commit to shopsys/shopsys that referenced this issue Mar 31, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants