Synapse update fails, impossible to restore

My YunoHost server

Hardware: RaspberryPi 4
YunoHost version: 11.2.5
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue




When I updated my system today, the synapse (v1.79) update failed again (because of setuptools, I tried all the solutions I could find on the forum or github, but none worked for me), and also this time, backing up fails as well, the system complains about a file named /opt/yunohost/....../METADATA and cannot install packages because of it.

I found a couple topics with the same issue except they did not have the same error as me, so I prefer asking first before randomly trying their solutions, even if they worked.
How can I fix that ? I thought a touch would do the trick but /opt/yunohost is empty …


Salut à tous,

En faisant ma mise à jour, j’ai à nouveau eu une erreur quand vint le tour de synapse (à cause de setuptools, j’ai essayé toutes les solutions que j’ai pu trouver sur le forum ou sur github mais rien n’y fait), et cette fois la restauration a aussi échoué, à cause d’un fichier manquant, /opt/yunohost...../METADATA, ce qui empêcherait l’installation de paquets.
Je suis tombé sur deux topics sur le même problème, mais avec un message d’erreur différent, du coup je préfère ne pas me hasarder à tenter leurs solutions, même si elles ont marché.

Merci / Thanks !

You have had the now famous setuptools issue with synapse.

Maybe, you can try to modify this file inside the backup archive of synapse.

Modify this file by keeping only the else part :
pip3 install --upgrade setuptools wheel pip
And then try again to restore using this modified file inside the archive.
Hope this gonna solve your issue.

Thanks for replying,

I tried as you suggested (and realised I need to learn more about tar), unfortunately it still fails to restore, I got the same error : ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info/METADATA' ,
should I try a touch opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info/METADATA ?

Did the error with setuptool disappeared, at least ?
I don’t know but why not trying the touch of METADATA
Just in case I give you the content of this file on my server :

/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info # cat METADATA 
Metadata-Version: 2.1
Name: cffi
Version: 1.15.1
Summary: Foreign Function Interface for Python calling C code.
Author: Armin Rigo, Maciej Fijalkowski
License: MIT
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: License :: OSI Approved :: MIT License
License-File: LICENSE
Requires-Dist: pycparser


Foreign Function Interface for Python calling C code.
Please see the `Documentation <>`_.


`Mailing list <!forum/python-cffi>`_

There are some other files in this folder :

/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info # ls -al
total 44
drwxr-xr-x   2 matrix-synapse root  4096 Sep 27  2022 .
drwxrwxrwx 138 matrix-synapse root 12288 Sep 21 18:06 ..
-rw-r--r--   1 matrix-synapse root    75 Sep 27  2022 entry_points.txt
-rw-r--r--   1 matrix-synapse root     4 Sep 27  2022 INSTALLER
-rw-r--r--   1 matrix-synapse root  1294 Sep 27  2022 LICENSE
-rw-r--r--   1 matrix-synapse root  1144 Sep 27  2022 METADATA
-rw-r--r--   1 matrix-synapse root  2992 Sep 27  2022 RECORD
-rw-r--r--   1 matrix-synapse root    19 Sep 27  2022 top_level.txt
-rw-r--r--   1 matrix-synapse root   150 Sep 27  2022 WHEEL
/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info # cat entry_points.txt 
cffi_modules = cffi.setuptools_ext:cffi_modules
/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info # cat INSTALLER 
/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info # cat RECORD,sha256=mYh4Dy89jojXJX-ab6fqsIjPaYOXIpOKMDkU4DGdzBE,1052976
/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info # cat top_level.txt 

This one look specific to the architecture (here ARM64)

/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info # cat WHEEL 
Wheel-Version: 1.0
Generator: bdist_wheel (0.37.1)
Root-Is-Purelib: false
Tag: cp39-cp39-manylinux_2_17_aarch64
Tag: cp39-cp39-manylinux2014_aarch64

The setuptools error is gone, indeed

but my /opt/yunohost folder is empty :

admin@purplehaze:~ $ ls -a /opt/yunohost/ 
.  .. 

So I assume the last update deleted the matrix-synapse folder for whatever reason, I my only option is to do a full clean install of synapse ? (Your file contents mus be specific to your server I guess)

Well, the .tar file contains the /opt/yunohost/matrix… folder. So I’d try a restauration of this folder manually and then try again a full restore.

Still doesnt work ><, here is what I did:

tar -xvf synapse-pre-upgrade1.tar apps/synapse/backup/opt/yunohost/matrix-synapse
cp -r apps/synapse/backup/opt/yunohost/matrix-synapse /opt/yunohost
## then restore

returned There is already a directory: /opt/yunohost/matrix-synapse, so the system complains whether the dir is here or not.

Do you think I can delete the test command that returns that error and retry ? It just does a few chmods after this : lines 62 and 220

Well, lost for lost, why not.
But I feel a bit shamy, cause, what I suggested before was a no luck to work, seeing the result.

Still doesn’t work, it complains again about metadata not being here although I manually restored it. I’ll just reinstall synapse from scratch, many thanks for your help

Hi Anthony,

I read your story. I got the same problem today, but in my case the suggestion by Catlover worked.

Do you still have the original backup file? You could try once more. I documented the steps to update the single file in the backup. It looks like many steps, but it does not take a lot of time.


I already reinstalled synapse, but I still have the original backup archive indeed, could you show how you did it then ?

My bad, sorry! I intended to link to it, but my thinking was less clear at the end of the night. Please have a look at [Solved] Synapse upgrade fails, restore fails (setuptools 60 vs 68? psycopg2?) - #2 by wbk ; keep in mind that you’ll have to replace your own file names of course :wink:

Give it a try!

So, I gave it a try, and it failed, I had that metadata error again, which was to be expected, actually I took a look at your logs and it seems you didn’t have that one.
I’ll just reinstall it from scratch, I only have a few users so it’s no big deal, thanks anyway !

Hi Anthony,

Sorry to not be of any help.

I actually had a look in the logs you posted before replying, I thought I could not find the metadata error in your logs either. I just had a look again, it seems we both have a metadata error, but not the same metadata error :wink:

On my Yunohost there was an error with metadata, WARNING - error: metadata-generation-failed :

2023-10-12 23:26:35,033: DEBUG - Requirement already satisfied: cffi in /opt/yunohost/matrix-synapse/lib/python3.9/site-packages (1.15.1)
2023-10-12 23:26:36,112: DEBUG - Collecting cffi
2023-10-12 23:26:36,113: DEBUG -   Obtaining dependency information for cffi from
2023-10-12 23:26:36,200: DEBUG -   Downloading cffi-1.16.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB)
2023-10-12 23:26:36,378: DEBUG - Requirement already satisfied: ndg-httpsclient in /opt/yunohost/matrix-synapse/lib/python3.9/site-packages (0.5.1)
2023-10-12 23:26:36,577: DEBUG - Requirement already satisfied: psycopg2 in /opt/yunohost/matrix-synapse/lib/python3.9/site-packages (2.9.7)
2023-10-12 23:26:36,946: DEBUG - Collecting psycopg2
2023-10-12 23:26:36,965: DEBUG -   Downloading psycopg2-2.9.9.tar.gz (384 kB)
2023-10-12 23:26:37,222: DEBUG -      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 384.9/384.9 kB 1.5 MB/s eta 0:00:00
2023-10-12 23:26:37,320: DEBUG -   Preparing metadata ( started
2023-10-12 23:26:38,195: DEBUG -   Preparing metadata ( finished with status 'error'
2023-10-12 23:26:38,209: WARNING -   error: subprocess-exited-with-error
2023-10-12 23:26:38,209: DEBUG - 
2023-10-12 23:26:38,209: WARNING -   × python egg_info did not run successfully.
2023-10-12 23:26:38,209: WARNING -   │ exit code: 1
2023-10-12 23:26:38,210: WARNING -   ╰─> [24 lines of output]
2023-10-12 23:26:38,216: WARNING -       [end of output]
2023-10-12 23:26:38,216: DEBUG - 
2023-10-12 23:26:38,216: WARNING -   note: This error originates from a subprocess, and is likely not a problem with pip.
2023-10-12 23:26:38,217: WARNING - error: metadata-generation-failed
2023-10-12 23:26:38,217: DEBUG - 
2023-10-12 23:26:38,217: WARNING - × Encountered error while generating package metadata.
2023-10-12 23:26:38,217: WARNING - ╰─> See above for output.
2023-10-12 23:26:38,217: DEBUG - 

It’s a pity when that is necessary, but it is a solution as well. Good luck with it! :slight_smile:

I have got the same problem on Raspberry Pi 4 : Synapse upgrade from 1.91.2 to 1.92.3 failed and I can’t restore 1.91.2.
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: ‘/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/cffi-1.15.1.dist-info/METADATA’
Did anybody find way to fix this issue ?
Thank you for your help.

Strange, I searched for cffi-1.15.1.dist-info, and got a result that does not mention cffi, but it does concern METADATA.

People seem to just mix and match metadata,

My error mentioned metadata as well, but it was another case than yours. I can’t test the suggestions in the Stackoverflow-thread, but maybe it got something that helps you on your way.

Thank you for your feed back.
I performed some test

  • Creation of METADATA empty file : Restore script failed (directory exist and script can’t create it)
  • Restoration thru SSH : Same error
  • I tried to fix it with solution in Github Issue 414 : Same error
  • I tried to restore an old synapse backup (September 28) : Same error
  • I installed an brand new yunohost on another hard drive and try to restore September 28 complete backup. All application restoration are OK except synapse ( There is only warning :
    2023-10-18 20:17:12,059: WARNING - …/settings/scripts/ /opt/yunohost/matrix-synapse/bin/pip3: /opt/yunohost/matrix-synapse/bin/python3: bad interpreter: No such file or directory
    Does anybody can give me some advices ?

You have been quite busy!

I’m out of suggestions. Just one left: does a new instance of Synapse install without problems? Perhaps you can compare the log of installing a new instance with the restore of the backup and find out which file is needed.

Both logs are very different. It is difficult to compare them. (Failed restore, new Synapse installation

:frowning: Yes, quite so.

There is a whole block almost identical; I put the logs in two windows beside each other and searched for synapse-ynh-deps; it occurs in the middle 30% of the restore log which corresponds with the area 20% to 40% (the second fifth) of the install log.

After that it diverts, restoring on the one hand and creating a database on the other (search for Adding user turnserver to group ssl-cert on both sides).

Then search for /home/yunohost.backup/tmp/ on the ‘restore’ side, which runs almost till the bottom. The two files convert on chown matrix-synapse:root -R /opt/yunohost/matrix-synapse, which is at 2023-10-19 19:53:03,174 on the restore side and at 2023-10-19 19:59:50,234 on the install side (and once more, at the bottom of the log).

Finally, the warning in the restore log occurs while running setuptools. It still tries to install the old version:

2023-10-19 19:53:03,622: DEBUG - ++ '[' -n /bin/bash -o -n '' ']'
2023-10-19 19:53:03,623: DEBUG - ++ hash -r
2023-10-19 19:53:03,623: DEBUG - + set -u
2023-10-19 19:53:03,623: DEBUG - ++ lsb_release --codename --short
2023-10-19 19:53:03,748: DEBUG - + '[' bullseye == bullseye ']'
2023-10-19 19:53:03,749: DEBUG - + pip3 install --upgrade setuptools==60.8.2 wheel pip
2023-10-19 19:53:03,751: WARNING - ../settings/scripts/ /opt/yunohost/matrix-synapse/bin/pip3: /opt/yunohost/matrix-synapse/bin/python3: bad interpreter: No such file or directory

The install log does not have a specific version in its command, and installs a much newer version:

2023-10-19 19:59:56,824: DEBUG - ++ '[' -n /bin/bash -o -n '' ']'
2023-10-19 19:59:56,824: DEBUG - ++ hash -r
2023-10-19 19:59:56,824: DEBUG - + set -u
2023-10-19 19:59:56,824: DEBUG - + pip3 install --upgrade setuptools wheel pip
2023-10-19 20:00:00,647: DEBUG - Looking in indexes:,
2023-10-19 20:00:00,649: DEBUG - Requirement already satisfied: setuptools in /opt/yunohost/matrix-synapse/lib/python3.9/site-packages (44.1.1)
2023-10-19 20:00:05,317: DEBUG - Collecting setuptools
2023-10-19 20:00:05,446: DEBUG -   Downloading (807 kB)
2023-10-19 20:00:06,185: DEBUG - Collecting wheel

Please have a look at the suggestion behind the link in my earlier post . I wrote the step-by-step instructions to replace the file in the archive. Take care to use the correct name for the backup, of course!