Ncp-dist-upgrade fails repeatedly

I’m running NC version 23.0.2, php 7.3.31-1~deb10u1 on buster release. It’s suggested to run ncp-dist-upgrade with /usr/local/etc/ncp-recommended.cfg

{
“nextcloud_version”: “23.0.2”,
“php_version”: “7.4”,
“release”: “bullseye”
}

Here follows the output of the failing upgrade and currently I’m a little bit lost:

sudo ncp-dist-upgrade

ATTENTION <<<
This is a dangerous process that is only guaranteed to work properly if you
have not made manual changes in the system. Backup the SD card first and
proceed at your own risk.

Note that this is not a requirement for NCP to continue working properly.
The current distribution will keep receiving updates for some time.

Do you want to continue? [y/N]
y
Maintenance mode enabled
Hit:1 http://archive.raspberrypi.org/debian buster InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:3 https://packages.cisofy.com/community/lynis/deb stable InRelease
Reading package lists… Done
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘php7.3-common’ instead of ‘php7.3-fileinfo’
The following packages were automatically installed and are no longer required:
libgd3 libsmbclient libsodium23 libxpm4 libxslt1.1 libzip4 php7.3-readline ttf-dejavu-core
Use ‘sudo apt autoremove’ to remove them.
The following packages will be REMOVED:
php* php-igbinary* php-imagick* php-redis* php-smbclient* php7.3* php7.3-bz2* php7.3-cli* php7.3-curl* php7.3-fpm* php7.3-gd* php7.3-intl* php7.3-json*
php7.3-ldap* php7.3-mbstring* php7.3-opcache* php7.3-xml* php7.3-zip*
0 upgraded, 0 newly installed, 18 to remove and 0 not upgraded.
After this operation, 11.2 MB disk space will be freed.
(Reading database … 112991 files and directories currently installed.)
Removing php (2:7.3+69) …
Removing php-redis (4.2.0-1) …
Removing php-igbinary (3.0.0-1) …
Removing php-imagick (3.4.3-4.1) …
Removing php-smbclient (0.9.0-3+b1) …
Removing php7.3 (7.3.31-1~deb10u1) …
Removing php7.3-bz2 (7.3.31-1~deb10u1) …
Removing php7.3-fpm (7.3.31-1~deb10u1) …
Conf php7.3-fpm disabled.
apache2_invoke prerm: Disable configuration php7.3-fpm
Removing php7.3-cli (7.3.31-1~deb10u1) …
Removing php7.3-curl (7.3.31-1~deb10u1) …
Removing php7.3-gd (7.3.31-1~deb10u1) …
Removing php7.3-intl (7.3.31-1~deb10u1) …
Removing php7.3-json (7.3.31-1~deb10u1) …
Removing php7.3-ldap (7.3.31-1~deb10u1) …
Removing php7.3-mbstring (7.3.31-1~deb10u1) …
Removing php7.3-opcache (7.3.31-1~deb10u1) …
Removing php7.3-xml (7.3.31-1~deb10u1) …
Removing php7.3-zip (7.3.31-1~deb10u1) …
Processing triggers for man-db (2.8.5-2) …
(Reading database … 112822 files and directories currently installed.)
Purging configuration files for php7.3-mbstring (7.3.31-1~deb10u1) …
Purging configuration files for php7.3-fpm (7.3.31-1~deb10u1) …
apache2_invoke postrm: Purging state for php7.3-fpm
dpkg: warning: while removing php7.3-fpm, directory ‘/etc/php/7.3/fpm/conf.d’ not empty so not removed
Purging configuration files for php7.3-json (7.3.31-1~deb10u1) …
Purging configuration files for php7.3-bz2 (7.3.31-1~deb10u1) …
Purging configuration files for php-smbclient (0.9.0-3+b1) …
Purging configuration files for php7.3-intl (7.3.31-1~deb10u1) …
Purging configuration files for php7.3-xml (7.3.31-1~deb10u1) …
Purging configuration files for php7.3-cli (7.3.31-1~deb10u1) …
dpkg: warning: while removing php7.3-cli, directory ‘/etc/php/7.3/cli/conf.d’ not empty so not removed
Purging configuration files for php7.3-opcache (7.3.31-1~deb10u1) …
Purging configuration files for php-igbinary (3.0.0-1) …
Purging configuration files for php7.3-zip (7.3.31-1~deb10u1) …
Purging configuration files for php7.3-ldap (7.3.31-1~deb10u1) …
Purging configuration files for php-imagick (3.4.3-4.1) …
Purging configuration files for php7.3-curl (7.3.31-1~deb10u1) …
Purging configuration files for php-redis (4.2.0-1) …
Purging configuration files for php7.3-gd (7.3.31-1~deb10u1) …
Processing triggers for systemd (241-7~deb10u8+rpi1) …
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libgd3 libsmbclient libsodium23 libxpm4 libxslt1.1 libzip4 php7.3-readline ttf-dejavu-core
Use ‘sudo apt autoremove’ to remove them.
The following packages will be REMOVED:
php7.3-mysql*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 355 kB disk space will be freed.
(Reading database … 112807 files and directories currently installed.)
Removing php7.3-mysql (7.3.31-1~deb10u1) …
(Reading database … 112794 files and directories currently installed.)
Purging configuration files for php7.3-mysql (7.3.31-1~deb10u1) …
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘php-redis’ instead of ‘php7.3-redis’
The following packages were automatically installed and are no longer required:
libgd3 libsmbclient libsodium23 libxpm4 libxslt1.1 libzip4 php7.3-readline ttf-dejavu-core
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘php7.3-common’ instead of ‘php7.3-exif’
The following packages were automatically installed and are no longer required:
libgd3 libsmbclient libsodium23 libxpm4 libxslt1.1 libzip4 php7.3-readline ttf-dejavu-core
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libgd3 libsmbclient libsodium23 libxpm4 libxslt1.1 libzip4 php7.3-readline ttf-dejavu-core
Use ‘sudo apt autoremove’ to remove them.
The following packages will be REMOVED:
php-bcmath* php7.3-bcmath*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 68.6 kB disk space will be freed.
(Reading database … 112794 files and directories currently installed.)
Removing php-bcmath (2:7.3+69) …
Removing php7.3-bcmath (7.3.31-1~deb10u1) …
(Reading database … 112782 files and directories currently installed.)
Purging configuration files for php7.3-bcmath (7.3.31-1~deb10u1) …
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libgd3 libsmbclient libsodium23 libxpm4 libxslt1.1 libzip4 php7.3-readline ttf-dejavu-core
Use ‘sudo apt autoremove’ to remove them.
The following packages will be REMOVED:
php7.3-gmp*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 85.0 kB disk space will be freed.
(Reading database … 112782 files and directories currently installed.)
Removing php7.3-gmp (7.3.31-1~deb10u1) …
(Reading database … 112773 files and directories currently installed.)
Purging configuration files for php7.3-gmp (7.3.31-1~deb10u1) …
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘php-imagick’ instead of ‘php7.3-imagick’
The following packages were automatically installed and are no longer required:
libgd3 libsmbclient libsodium23 libxpm4 libxslt1.1 libzip4 php7.3-readline ttf-dejavu-core
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Get:1 http://archive.raspberrypi.org/debian bullseye InRelease [23.6 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Hit:3 https://packages.cisofy.com/community/lynis/deb stable InRelease
Get:4 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB]
Get:5 http://archive.raspberrypi.org/debian bullseye/main armhf Packages [267 kB]
Get:6 http://raspbian.raspberrypi.org/raspbian bullseye/contrib armhf Packages [60.2 kB]
Get:7 http://raspbian.raspberrypi.org/raspbian bullseye/non-free armhf Packages [106 kB]
Get:8 http://raspbian.raspberrypi.org/raspbian bullseye/rpi armhf Packages [1,360 B]
Fetched 13.7 MB in 10s (1,353 kB/s)
Reading package lists… Done
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Error!
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-6+rpi1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
Something went wrong. Fix it and try again

I stopped screwing with ncp-dist-upgrade. I had a clean VirtualBox VM with fresh Debian 10 and NCP 2.2. Nothing but failure after failure to upgrade after restoring a VM backup. I finally gave up.

I built a new Debian 11 (bullseye) system. I installed NCP from install.sh. Then, I manually used the steps in the upgrade script to upgrade PHP to 7.4. Finally, I restored the NCP export and Nextcloud back.

The ncp-dist-upgrade script’s only value to me was as a template to upgrade PHP. Even in that uncovered countless incorrectly listed php repository packages. Those are probably the source of your dependency error using the script.

No it manually with a new build. I’ve had no problems since.

I had the same problem that I tried the upgrade again and again (unsuccessfully). Finally I found a solution for my environment and made 2 changes to ncp-dist-upgrade:

# install latest distro
apt-get update
apt-get remove gcc-8-base -y                   <-- added this line
apt-get dist-upgrade -y
# install latest PHP version
release_new=$(jq -r '.release' < "${new_cfg}")
# the default repo in bullseye is bullseye-security
#release_new="${release_new}-security"        <-- commented out this one
php_ver_new=$(jq -r '.php_version' < "${new_cfg}")

The second modification should be fixed now.