make test: "bz2 extension missing" but php-bz2 is installed
When I run make test it skips 1 test with the following message:
SKIP Full test for face recognition - download models, detect faces, landmark detection and face recognition. [tests/integration_face_recognition.phpt] reason: bz2 extension missing
However the bz2 extension is installed and face recognition in nextcloud is working...
One possiblity is the php-bz2 package defaults to version 7.4 for some people while for others it may be 8.0 or 8.1. Probably worth double-checking that php7.4-bz2 (the versioned package name on Ubuntu/Debian) is specifically installed.
And if you do have multiple PHP versions, you'll want to specify the version in both the phpize and ./configure commands. phpize7.4 and ./configure --with-php-config=/usr/bin/php-config7.4 are likely what's needed. You can see the difference this makes by looking at what make test would now show: all tests get skipped, the wrong PHP version is listed, or a complaint that the ini file cannot be found during tests.
NOTE: if you do need to start versioning the phpize and configure commands—and do ensure they match—you'll likely want to use a make clean as the build system doesn't appear to realize it should do a rebuild.
Example of wrong PHP being used during make test:
Don't forget to run 'make test'.
/bin/grep: /etc/php/8.0/cli/conf.d/20-pdlib.ini: No such file or directory
=====================================================================
PHP : /usr/bin/php8.0
Warning: PHP Startup: pdlib: Unable to initialize module
Module compiled with module API=20190902
PHP compiled with module API=20200930
These options need to match
in Unknown on line 0
PHP_SAPI : cli
PHP_VERSION : 8.0.12
ZEND_VERSION: 4.0.12
PHP_OS : Linux - Linux … 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64
INI actual : /home/…/pdlib/tmp-php.ini
More .INIs :
CWD : /home/…/pdlib
Extra dirs :
VALGRIND : Not used
=====================================================================
TIME START 2021-11-11 20:30:24
=====================================================================
SKIP Check for pdlib presence [tests/001.phpt]
SKIP Basic tests for chinese_whispers [tests/chinese_whispers_basic.phpt]
SKIP Edge given in edges array for chinese_whispers functions is associative array [tests/chinese_whispers_edge_associative_array_error.phpt]
SKIP Edge elements given in edges array for chinese_whispers functions are not of long type [tests/chinese_whispers_edge_elements_not_long.phpt]
SKIP Edge given in edges array for chinese_whispers functions is not having all values to be arrays with 2 elements [tests/chinese_whispers_edge_not_2_element_error.phpt]
SKIP Edge given in edges array is not array for chinese_whispers functions [tests/chinese_whispers_edge_not_array_error.phpt]
SKIP Args given to chinese_whispers functions is not correct [tests/chinese_whispers_wrong_arg_type_error.phpt]
SKIP Testing CnnFaceDetection constructor without arguments [tests/cnn_face_detection_ctor_error.phpt]
SKIP Testing CnnFaceDetection constructor with model that do not exist [tests/cnn_face_detection_ctor_model_not_found_error.phpt]
SKIP Frontal face detection. [tests/dlib_face_detection.phpt] reason: pdlib extension missing
SKIP Testing FaceLandmarkDetection constructor without arguments [tests/face_landmark_detection_ctor_error.phpt]
SKIP Testing FaceRecognition constructor without arguments [tests/face_recognition_ctor_error.phpt]
SKIP Full test for face recognition - download models, detect faces, landmark detection and face recognition. [tests/integration_face_recognition.phpt] reason: pdlib extension missing
SKIP Basic tests for dlib_vector_length [tests/vector_length.phpt]
SKIP Just test php extension version [tests/version.phpt]
=====================================================================
TIME END 2021-11-11 20:30:24
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 15
---------------------------------------------------------------------
Number of tests : 15 0
Tests skipped : 15 (100.0%) --------
Thanks for your reply however I only have php7.4 installed (also the php7.4-bz2 module). I tried your phpize and configure commands anyway but with the same result.
Good, sounds like everything's at least building against the correct libraries. One last thing and I was able to get from reproducing the single skip to a full 15/15 passing.
The test suite copies the default PHP ini file (/etc/php/7.4/cli/php.ini in my case) which doesn't have bz2 enabled. You can modify the Makefile's test recipe by adding a sed command to find/replace the line with the precise location of the bz2 extension. The version in the path below is from phpize7.4, so here's what a diff of that might look like:
--- Makefile.orig 2021-11-11 18:54:25.864750573 -0500
+++ Makefile 2021-11-11 19:01:00.477879176 -0500
@@ -141,6 +141,7 @@
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
+ sed -i 's#^;extension=bz2#extension=/usr/lib/php/20190902/bz2.so#g' $(top_builddir)/tmp-php.ini; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
With that I got a full 15/15 test run:
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 16
---------------------------------------------------------------------
Number of tests : 15 15
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Tests passed : 15 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken : 2 seconds
=====================================================================
I have the same problem, php8.1:
root@ncloud:~/pdlib# make test
Build complete.
Don't forget to run 'make test'.
=====================================================================
PHP : /usr/bin/php8.1
PHP_SAPI : cli
PHP_VERSION : 8.1.2-1ubuntu2.13
ZEND_VERSION: 4.1.2
PHP_OS : Linux - Linux ncloud 5.15.85-1-pve #1 SMP PVE 5.15.85-1 (2023-02-01T00:00Z) x86_64
INI actual : /root/pdlib/tmp-php.ini
More .INIs :
---------------------------------------------------------------------
PHP : /usr/bin/phpdbg8.1
PHP_SAPI : phpdbg
PHP_VERSION : 8.1.2-1ubuntu2.13
ZEND_VERSION: 4.1.2
PHP_OS : Linux - Linux ncloud 5.15.85-1-pve #1 SMP PVE 5.15.85-1 (2023-02-01T00:00Z) x86_64
INI actual : /root/pdlib/tmp-php.ini
More .INIs :
---------------------------------------------------------------------
CWD : /root/pdlib
Extra dirs :
VALGRIND : Not used
=====================================================================
TIME START 2023-08-08 19:10:10
=====================================================================
PASS Check for pdlib presence [tests/001.phpt]
PASS Basic tests for chinese_whispers [tests/chinese_whispers_basic.phpt]
PASS Edge given in edges array for chinese_whispers functions is associative array [tests/chinese_whispers_edge_associative_array_error.phpt]
PASS Edge elements given in edges array for chinese_whispers functions are not of long type [tests/chinese_whispers_edge_elements_not_long.phpt]
PASS Edge given in edges array for chinese_whispers functions is not having all values to be arrays with 2 elements [tests/chinese_whispers_edge_not_2_element_error.phpt]
PASS Edge given in edges array is not array for chinese_whispers functions [tests/chinese_whispers_edge_not_array_error.phpt]
PASS Args given to chinese_whispers functions is not correct [tests/chinese_whispers_wrong_arg_type_error.phpt]
PASS Testing CnnFaceDetection constructor without arguments [tests/cnn_face_detection_ctor_error.phpt]
PASS Testing CnnFaceDetection constructor with model that do not exist [tests/cnn_face_detection_ctor_model_not_found_error.phpt]
PASS Frontal face detection. [tests/dlib_face_detection.phpt]
PASS Testing FaceLandmarkDetection constructor without arguments [tests/face_landmark_detection_ctor_error.phpt]
PASS Testing FaceRecognition constructor without arguments [tests/face_recognition_ctor_error.phpt]
SKIP Full test for face recognition - download models, detect faces, landmark detection and face recognition. [tests/integration_face_recognition.phpt] reason: bz2 extension missing
PASS Basic tests for dlib_vector_length [tests/vector_length.phpt]
PASS Just test php extension version [tests/version.phpt]
=====================================================================
TIME END 2023-08-08 19:10:11
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 16
---------------------------------------------------------------------
Number of tests : 15 14
Tests skipped : 1 ( 6.7%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Tests passed : 14 ( 93.3%) (100.0%)
---------------------------------------------------------------------
Time taken : 1 seconds
=====================================================================
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it. You can then email it to [email protected] later.
Do you want to send this report now? [Yns]: n
root@ncloud:~/pdlib#
Had to add the sed line too. Using the variable $(EXTENSION_DIR) should make it generic for custom installation paths...
+++ Makefile
@@ -144,9 +144,9 @@
if test "$$INI_SCANNED_PATH"; then \
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
+ sed -i 's#^;extension=bz2#extension=$(EXTENSION_DIR)/bz2.so#g' $(top_builddir)/tmp-php.ini; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
It looks like phpize creates build/Makefile.global which is the first place this can be addressed. Later, ./configure creates Makefile where we've been inserting that single line.