Docker image: setup warning missing bz2 after update to NC 28.0.0

Hello I upgraded today from Hub 7 to Hub 8 and now Iam getting this:
This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them: bz2.
Besides the error log message: 6975 errors in the logs since 7. Dezember 2023 but this is apparently a bug right now…

Info:
PHP 8.2.13 (cli) (built: Dec 12 2023 22:02:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.13, Copyright (c) Zend Technologies
with Zend OPcache v8.2.13, Copyright (c), by Zend Technologies

[PHP Modules]
apcu
bcmath
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gmp
hash
iconv
imagick
intl
json
ldap
libxml
mbstring
memcached
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
Phar
posix
random
readline
redis
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

So I have tried the following:
apt-get install php8.2-bz2

Which gives me the following output:
Package php8.2-bz2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘php8.2-bz2’ has no installation candidate

I then tried to follow this guide: How to install/upgrade PHP 8.2 on Debian and Ubuntu systems • PHP.Watch

I ran inside the container:
sudo apt install apt-transport-https lsb-release ca-certificates wget -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c ‘echo “deb Index of /php/ $(lsb_release -sc) main” > /etc/apt/sources.list.d/php.list’
sudo apt update

apt install php8.2-{bz2}

Nothing did seem to help so any help or suggestions would be appreciated.

3 Likes

Associated Github issue regarding this warning for the Docker container

When using the docker container you can run:

docker compose exec nextcloud_app apt-get update && apt-get install -y libbz2-dev && docker-php-ext-install bz2

and then restart the container

docker compose restart nextcloud_app
3 Likes

I have tried this:

docker exec nextcloud-app-1 apt-get update && apt-get install -y libbz2-dev && docker-php-ext-install bz2

I used docker exec container-name because I created nextcloud as a portainer stack and this command wouldnt work:
docker compose exec nextcloud-app-1 apt-get update && apt-get install -y libbz2-dev && docker-php-ext-install bz2

This is the Output:

Hit:1 Index of /debian bookworm InRelease
Get:2 Index of /debian bookworm-updates InRelease [52.1 kB]
Get:3 Index of /debian-security bookworm-security InRelease [48.0 kB]
Get:4 Index of /debian-security bookworm-security/main amd64 Packages [127 kB]
Fetched 227 kB in 0s (671 kB/s)
Reading package lists…
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
bzip2-doc
The following NEW packages will be installed:
bzip2-doc libbz2-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 523 kB of archives.

After this operation, 706 kB of additional disk space will be used.
Get:1 Index of /debian-security buster/updates/main amd64 bzip2-doc all 1.0.6-9.2~deb10u2 [493 kB]
Get:2 Index of /debian-security buster/updates/main amd64 libbz2-dev amd64 1.0.6-9.2~deb10u2 [30.2 kB]
Fetched 523 kB in 0s (7671 kB/s)
Selecting previously unselected package bzip2-doc.
(Reading database … 42435 files and directories currently installed.)
Preparing to unpack …/bzip2-doc_1.0.6-9.2~deb10u2_all.deb …
Unpacking bzip2-doc (1.0.6-9.2~deb10u2) …
Selecting previously unselected package libbz2-dev:amd64.
Preparing to unpack …/libbz2-dev_1.0.6-9.2~deb10u2_amd64.deb …
Unpacking libbz2-dev:amd64 (1.0.6-9.2~deb10u2) …
Setting up bzip2-doc (1.0.6-9.2~deb10u2) …
Setting up libbz2-dev:amd64 (1.0.6-9.2~deb10u2) …
-bash: docker-php-ext-install: command not found

Had to split the output because of a link limit for new users.

I just ran:
docker exec nextcloud-app-1 docker-php-ext-install bz2

Output:
Configuring for:
PHP Api Version: 20220829
Zend Module Api No: 20220829
Zend Extension Api No: 420220829
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for a sed that does not truncate output… /usr/bin/sed
checking for pkg-config… /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0… yes
checking for cc… cc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether the compiler supports GNU C… yes
checking whether cc accepts -g… yes
checking for cc option to enable C11 features… none needed
checking how to run the C preprocessor… cc -E
checking for icc… no
checking for suncc… no
checking for system library directory… lib
checking if compiler supports -Wl,-rpath,… yes
checking build system type… x86_64-pc-linux-gnu
checking host system type… x86_64-pc-linux-gnu
checking target system type… x86_64-pc-linux-gnu
checking for PHP prefix… /usr/local
checking for PHP includes… -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory… /usr/local/lib/php/extensions/no-debug-non-zts-20220829
checking for PHP installed headers prefix… /usr/local/include/php
checking if debug is enabled… no
checking if zts is enabled… no
checking for gawk… no
checking for nawk… nawk
checking if nawk is broken… no
checking for BZip2 support… yes, shared
checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution

1 Like

Those commands worked for me.

Hello,

As I don’t use compose to run my containers but Ansible, and as inside the container Im user ID 1001 I had to enter the container as root, to be granted to install packages:

docker exec -u 0 -ti nextcloud-app /bin/bash

And then:

apt-get update && apt-get install -y libbz2-dev && docker-php-ext-install bz2

Unfortunately it didn’t solved the warning message. I don’t get the point actually, if we install something inside the container, those changes won’t be kept as we restart the container, maybe we should bind some volume ? Or in the Dockerfile they schould ad some line like:

RUN apt-get update && apt-get install -y libbz2-dev && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install bz2
1 Like

Update I just fired up Nextcloud again and rerun these commands and this time it worked.

apt-get update && apt-get install -y libbz2-dev && docker-php-ext-install bz2

1 Like

The real question is.
Why is this not a part of the official docker ?

All this is an work around, right ?

4 Likes

There is a discussion about this on GitHub, so if you want to share your reasoning with the devs of the Docker image, that would be the place to do it: After upgrading 28.0.0 bz2 module missing · Issue #2118 · nextcloud/docker · GitHub

That beeing said, according to this comment it seems that this module is not actually used by anything, or at least not by any of the the standard Nextcloud apps. So unless you’re experiencing any issues or a specific app explicitly requires bz2, its probably save to ignore the warning, at least for the time beeing.

Please also note that the Nextcloud Docker Images are a community project maintained by volunteers, which means that you are not entitled to any kind of support or the implementation of your feature requests. So please be nice if any of you decides to join the discussion over there… :slight_smile:

1 Like

you might be right technically right regarding bz2 usage but setup warnings are core elements and don’t come from the docker project - this one is not to blame and only must adopt the new requirements - btw the “community” Docker project is hosted inside of Github organization “Nextcloud” and must be considered as “official”

I just summarised what I took away from the discussion in the linked GitHub issue, and maybe it will help some people sleep better, knowing that their Nextcloud won’t explode because of this warning… :wink:

If they had asked me, I would have said: Just install the darn package and ship it with the next release! But they didn’t ask… :wink:

1 Like

thanks. this fix worked on nc 28.0.1

i had to run the command this way:

docker exec -it nextcloud-app-1 bash

and then:

apt-get update && apt-get install -y libbz2-dev && docker-php-ext-install bz2

output:

Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  bzip2-doc
The following NEW packages will be installed:
  bzip2-doc libbz2-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 545 kB of archives.
After this operation, 724 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 bzip2-doc all 1.0.8-5 [514 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 libbz2-dev amd64 1.0.8-5+b1 [30.9 kB]
Fetched 545 kB in 0s (3487 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package bzip2-doc.
(Reading database ... 17427 files and directories currently installed.)
Preparing to unpack .../bzip2-doc_1.0.8-5_all.deb ...
Unpacking bzip2-doc (1.0.8-5) ...
Selecting previously unselected package libbz2-dev:amd64.
Preparing to unpack .../libbz2-dev_1.0.8-5+b1_amd64.deb ...
Unpacking libbz2-dev:amd64 (1.0.8-5+b1) ...
Setting up bzip2-doc (1.0.8-5) ...
Setting up libbz2-dev:amd64 (1.0.8-5+b1) ...
Configuring for:
PHP Api Version:         20220829
Zend Module Api No:      20220829
Zend Extension Api No:   420220829
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20220829
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for BZip2 support... yes, shared
checking for BZip2 in default path... found in /usr
checking for BZ2_bzerror in -lbz2... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
/bin/bash /usr/src/php/ext/bz2/libtool --mode=compile cc -I. -I/usr/src/php/ext/bz2 -I/usr/src/php/ext/bz2/include -I/usr/src/php/ext/bz2/main -I/usr/src/php/ext/bz2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE    -DZEND_COMPILE_DL_EXT=1 -c /usr/src/php/ext/bz2/bz2.c -o bz2.lo  -MMD -MF bz2.dep -MT bz2.lo
mkdir .libs
 cc -I. -I/usr/src/php/ext/bz2 -I/usr/src/php/ext/bz2/include -I/usr/src/php/ext/bz2/main -I/usr/src/php/ext/bz2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DZEND_COMPILE_DL_EXT=1 -c /usr/src/php/ext/bz2/bz2.c -MMD -MF bz2.dep -MT bz2.lo  -fPIC -DPIC -o .libs/bz2.o
/bin/bash /usr/src/php/ext/bz2/libtool --mode=compile cc -I. -I/usr/src/php/ext/bz2 -I/usr/src/php/ext/bz2/include -I/usr/src/php/ext/bz2/main -I/usr/src/php/ext/bz2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE    -DZEND_COMPILE_DL_EXT=1 -c /usr/src/php/ext/bz2/bz2_filter.c -o bz2_filter.lo  -MMD -MF bz2_filter.dep -MT bz2_filter.lo
 cc -I. -I/usr/src/php/ext/bz2 -I/usr/src/php/ext/bz2/include -I/usr/src/php/ext/bz2/main -I/usr/src/php/ext/bz2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DZEND_COMPILE_DL_EXT=1 -c /usr/src/php/ext/bz2/bz2_filter.c -MMD -MF bz2_filter.dep -MT bz2_filter.lo  -fPIC -DPIC -o .libs/bz2_filter.o
/bin/bash /usr/src/php/ext/bz2/libtool --mode=link cc -shared -I/usr/src/php/ext/bz2/include -I/usr/src/php/ext/bz2/main -I/usr/src/php/ext/bz2 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE  -Wl,-O1 -pie  -o bz2.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/src/php/ext/bz2/modules  bz2.lo bz2_filter.lo -lbz2
cc -shared  .libs/bz2.o .libs/bz2_filter.o  -lbz2  -Wl,-O1 -Wl,-soname -Wl,bz2.so -o .libs/bz2.so
creating bz2.la
(cd .libs && rm -f bz2.la && ln -s ../bz2.la bz2.la)
/bin/bash /usr/src/php/ext/bz2/libtool --mode=install cp ./bz2.la /usr/src/php/ext/bz2/modules
cp ./.libs/bz2.so /usr/src/php/ext/bz2/modules/bz2.so
cp ./.libs/bz2.lai /usr/src/php/ext/bz2/modules/bz2.la
PATH="$PATH:/sbin" ldconfig -n /usr/src/php/ext/bz2/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/src/php/ext/bz2/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

+ strip --strip-all modules/bz2.so
Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20220829/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o -o -name \*.dep | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la      modules/* libs/*
rm -f ext/opcache/jit/zend_jit_x86.c
rm -f ext/opcache/jit/zend_jit_arm64.c
rm -f ext/opcache/minilua
1 Like

How could you do it in a permanent way? As soon when the container is recreated, bz2 disappears.

I’m getting rid of NC on Truenas because of stuff like this. Workaround guides for problems are always for docker images or native installs, which are a bit different for Truenas installs and I dont have the expertise to figure out what the difference needs to be.

I will make an SMB share with my folders on it, and let NC use that as the datastore. That way NC just runs on Debian and that’s that. No docker, nothing hard to manage.

You would need to create a Dockerfile and delcare the nextcloud image, your custom commands and, then build a customized image using said Dockerfile

That said there looks to be little point as the warning is the only new thing and may be removed in the future as nothing actually uses bz2

The advice from the GitHub issue is that this warning can safely be ignored at this time

1 Like

Hello,

I tried to run the commands you specify but I got errors because bash executes just the first command in docker compose and the rest on the bash session itself.

So I had to use these commands separately:

docker compose exec app apt update
docker compose exec app apt-get install -y libbz2-dev
docker compose exec app docker-php-ext-install bz2
docker compose restart

*Being app the name of the docker service corresponding to Nextcloud instance.

Also, everytime you update the docker image you’ll need to install this module, so if you don’t want to make a Dockerfile to include it, you can make a script (that’s what I did) to manually run after an update.

 #!/bin/bash
dcpath='/root/docker-apps/nextcloud/docker-compose.yml'
app='nextcloud-app'

/usr/bin/docker compose -f $dcpath exec -u 0 $app apt update
/usr/bin/docker compose -f $dcpath exec -u 0 $app apt-get install -y libbz2-dev
/usr/bin/docker compose -f $dcpath exec -u 0 $app docker-php-ext-install bz2
/usr/bin/docker compose -f $dcpath restart

Remember to change the dcpath and app variables to suit your setup.

Thank you for your help, @dugite-code!
Mauricio

Is there a reason why isn’t this installed by default inside the docker image? The changes are gone after the container down&up …

The bz2 check is slated for removal in the next point release. As it turns out it isn’t required for anything. [stable28] Remove disputed bz2 check by backportbot[bot] · Pull Request #43013 · nextcloud/server · GitHub

1 Like