matrix-docker-ansible-deploy icon indicating copy to clipboard operation
matrix-docker-ansible-deploy copied to clipboard

cannot import name 'environmentfilter' from 'jinja2.filters'

Open enes-oerdek opened this issue 2 years ago • 1 comments

Describe the bug I followed the following guide to upgrade my matrix instance: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/maintenance-upgrading-services.md

When trying to start the services, I get the following error.

` TASK [matrix-base : Ensure Matrix group is created] ************************************************************************************************************* [WARNING]: an unexpected error occurred during Jinja2 environment setup: cannot import name 'environmentfilter' from 'jinja2.filters' (/home/x/.local/lib/python3.10/site-packages/jinja2/filters.py) line 0 fatal: [x]: FAILED! => msg: |- The conditional check 'run_setup | bool' failed. The error was: template error while templating string: cannot import name 'environmentfilter' from 'jinja2.filters' (/home/x/.local/lib/python3.10/site-packages/jinja2/filters.py) line 0. String: {% if run_setup | bool %} True {% else %} False {% endif %}

The error appears to be in '/home/x/git/matrix-docker-ansible-deploy/roles/matrix-base/tasks/setup_matrix_user.yml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Ensure Matrix group is created
  ^ here

PLAY RECAP ****************************************************************************************************************************************************** x : ok=1 changed=0 unreachable=0 failed=1 skipped=10 rescued=0 ignored=0
`

To Reproduce

Run following commands `ansible-playbook -i inventory/hosts setup.yml --tags=setup-all

ansible-playbook -i inventory/hosts setup.yml --tags=start`

Expected behavior Instance is upgraded and started.

Additional context Issue occurs because I recently upgraded my local os. Solution is simple. The issue can be resolved if you install an older version jinja2 by entering following: pip install 'jinja2<3.1'

I hope this helps in case you also run into this issue.

enes-oerdek avatar Sep 06 '22 14:09 enes-oerdek

Thanks, @enes-oerdek! I was having the issue described in #2300 but then after upgrading jinja2 from 2.11.7 to 3.1.2 as per the advice there, ran into this problem. Your suggestion of downgrading jinja2 back to 3.0.3 fixed the issue.

devinberg avatar Dec 13 '22 00:12 devinberg