Composer / php version

Hello,

I have a problem, i have this message on my webgui of Librenms

`Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1

I have php 8.1.11:

Component | Version
--------- | -------
LibreNMS  | 22.10.0-22-g707f2cd29 (2022-10-23T20:00:29+02:00)
DB Schema | 2022_09_03_091314_update_ports_adsl_table_with_defaults (246)
PHP       | 8.1.11
Python    | 3.9.2
Database  | MariaDB 10.5.15-MariaDB-0+deb11u1
RRDTool   | 1.7.2
SNMP      | 5.9
===========================================

I must upgrade composer? How?

thanks

edit /opt/librenms/vendor/composer/platform_check.php

<?php

// platform_check.php @generated by Composer

$issues = array();

- if (!(PHP_VERSION_ID >= 80100)) {
+ if (!(PHP_VERSION_ID <= 80100)) {
    $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
}
1 Like

I had the same issue. Seems to be a wrong check in /opt/librenms/vendor/composer/platform_check.php

For the moment just commented the 3 lines

//if (!(PHP_VERSION_ID >= 80100)) {
// $issues[] = 'Your Composer dependencies require a PHP version “>= 8.1.0”. You are running ’ . PHP_VERSION . ‘.’;
//}

1 Like

No official patch for this ?

Hello,
Without touching the configuration of the php files. I executed this command and the problem was solved.

 ./composer dump-autoload
1 Like

Have a look here : Composer php minimum version to 8.1 by murrant · Pull Request #14494 · librenms/librenms (github.com)

Thanks @lynch4fr

This confirms the source of the problem, not properly updated installs.

Make sure you are following the official docs for updating a LibreNMS install.

dump-autoload is part of the dependency update process:

./scripts/composer_wrapper.php install --no-dev

Not better :thinking:

root@supervision:~# su - librenms
librenms@supervision:~$ ./scripts/composer_wrapper.php install --no-dev

LibreNMS\ComposerHelper::preInstall
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package php-cs-fixer/diff is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel-notification-channels/webpush
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: librenms/laravel-vue-i18n-generator
Discovered Package: mews/purifier
Discovered Package: nesbot/carbon
Discovered Package: php-flasher/flasher-laravel
Discovered Package: tightenco/ziggy
Package manifest generated successfully.
66 packages you are using are looking for funding.
Use the composer fund command to find out more!
LibreNMS\ComposerHelper::postInstall
Illuminate\Foundation\ComposerScripts::postInstall
@php artisan vue-i18n:generate --multi-locales --format=umd
@php artisan view:cache
Compiled views cleared!
Blade templates cached successfully!
@php artisan optimize
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
Routes cached successfully!
Files cached successfully!
@php artisan config:clear
Configuration cache cleared!
scripts/dynamic_check_requirements.py || pip3 install --user -r requirements.txt || :

In wich directory have you launched this command ?
As librenms user or root ?

Tried : composer dump-autoload

librenms@supervision:~$ composer dump-autoload
PHP Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Console/Helper/HelperSet.php on line 103

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Console/Helper/HelperSet.php on line 103
Deprecation Notice: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/share/php/JsonSchema/Constraints/Constraint.php:48
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/ArrayRepository.php:277
Deprecation Notice: Return type of Symfony\Component\Process\Process::getIterator($flags = 0) should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Process/Process.php:622
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/ArrayRepository.php:277
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/ArrayRepository.php:277
Generating optimized autoload files
Deprecation Notice: Return type of Symfony\Component\Finder\Finder::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Finder.php:620
Deprecation Notice: Return type of Symfony\Component\Finder\Finder::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Finder.php:701
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\FileTypeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php:42
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::getChildren() should either be compatible with RecursiveDirectoryIterator::getChildren(): RecursiveDirectoryIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php:85
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::rewind() should either be compatible with FilesystemIterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php:113
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::current() should either be compatible with FilesystemIterator::current(): SplFileInfo|FilesystemIterator|string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php:61
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php:55
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::hasChildren() should either be compatible with RecursiveIterator::hasChildren(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php:74
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::getChildren() should either be compatible with RecursiveIterator::getChildren(): ?RecursiveIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php:79
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\FilenameFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php:28
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\PathFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Finder/Iterator/PathFilterIterator.php:27

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel-notification-channels/webpush
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: librenms/laravel-vue-i18n-generator
Discovered Package: mews/purifier
Discovered Package: nesbot/carbon
Discovered Package: php-flasher/flasher-laravel
Discovered Package: tightenco/ziggy
Package manifest generated successfully.
Generated optimized autoload files containing 6476 classes

Your system composer is incompatible with the php version you are using. change composer/opt/librenms/scripts/composer_wrapper.php

It turns out this problem is slightly bigger than this.
I installed php8.1 - but for some or other reason php-fpm 7.4 was still in use?

This resolved it for me on debian 11, apache2. Moved over the php fpm socket config.

cd /etc/php
cp 7.3/fpm/pool.d/librenms.conf 8.1/fpm/pool.d/
systemctl restart  apache2 
systemctl restart php8.1-fpm

sorry i dont know what to change in this file


Would’nt be easier to uninstall some php8 lib and install with /opt/librenms/scripts/composer_wrapper.php ?

Or is it possible to reinstall and restore database and config ?

don’t work for me

Do not edit the wrapper file… replace “composer” in commands like this ./scripts/composer_wrapper.php dump-autoload that will use LibreNMS’ bundled composer instead of your system one, which is broken. You may want to apt remove composer (or whatever for your os)

If you suspect there is a problem with your dependencies, you can re-install them:

rm -rf vendor
./scripts/composer_wrapper.php install --no-dev

root@supervision:/etc/php# apt remove composer
Lecture des listes de paquets… Fait
Construction de l’arbre des dépendances… Fait
Lecture des informations d’état… Fait
Les paquets suivants ont été installés automatiquement et ne sont plus nécessaires :
jsonlint php-composer-ca-bundle php-composer-semver php-composer-spdx-licenses
php-composer-xdebug-handler php-json-schema php-psr-container php-psr-log php-react-promise
php-symfony-console php-symfony-filesystem php-symfony-finder php-symfony-polyfill-php80
php-symfony-process php-symfony-service-contracts unzip
Veuillez utiliser « apt autoremove » pour les supprimer.
Les paquets suivants seront ENLEVÉS :
composer
0 mis à jour, 0 nouvellement installés, 1 à enlever et 18 non mis à jour.
Après cette opération, 2 299 ko d’espace disque seront libérés.
Souhaitez-vous continuer ? [Y/n] Y
(Lecture de la base de données… 64263 fichiers et répertoires déjà installés.)
Suppression de composer (2.0.9-2+deb11u1) …
Traitement des actions différées (« triggers ») pour man-db (2.9.4-2) …

librenms@supervision:~$ ./scripts/composer_wrapper.php install --no-dev

LibreNMS\ComposerHelper::preInstall
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package php-cs-fixer/diff is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel-notification-channels/webpush
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: librenms/laravel-vue-i18n-generator
Discovered Package: mews/purifier
Discovered Package: nesbot/carbon
Discovered Package: php-flasher/flasher-laravel
Discovered Package: tightenco/ziggy
Package manifest generated successfully.
66 packages you are using are looking for funding.
Use the composer fund command to find out more!
LibreNMS\ComposerHelper::postInstall
Illuminate\Foundation\ComposerScripts::postInstall
@php artisan vue-i18n:generate --multi-locales --format=umd
@php artisan view:cache
Compiled views cleared!
Blade templates cached successfully!
@php artisan optimize
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
Routes cached successfully!
Files cached successfully!
@php artisan config:clear
Configuration cache cleared!
scripts/dynamic_check_requirements.py || pip3 install --user -r requirements.txt || :

librenms@supervision:~$ ./scripts/composer_wrapper.php dump-autoload
Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel-notification-channels/webpush
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: librenms/laravel-vue-i18n-generator
Discovered Package: mews/purifier
Discovered Package: nesbot/carbon
Discovered Package: php-flasher/flasher-laravel
Discovered Package: tightenco/ziggy
Package manifest generated successfully.
Generated optimized autoload files containing 6476 classes

Something strange on this :
root@supervision:~# systemctl restart php8.1-fpm
Job for php8.1-fpm.service failed because the control process exited with error code.
See “systemctl status php8.1-fpm.service” and “journalctl -xe” for details.

oct. 26 00:31:19 supervision php-fpm8.1[2289]: [26-Oct-2022 00:31:19] ERROR: Another FPM instance seems to already listen on /run/php-fpm-librenms.sock
oct. 26 00:31:19 supervision php-fpm8.1[2289]: [26-Oct-2022 00:31:19] ERROR: FPM initialization failed
oct. 26 00:31:19 supervision systemd[1]: php8.1-fpm.service: Main process exited, code=exited, status=78/CONFIG
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: Debian -- User Support
░░
░░ An ExecStart= process belonging to unit php8.1-fpm.service has exited.
░░
░░ The process’ exit code is ‘exited’ and its exit status is 78.
oct. 26 00:31:19 supervision systemd[1]: php8.1-fpm.service: Failed with result ‘exit-code’.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: Debian -- User Support
░░
░░ The unit php8.1-fpm.service has entered the ‘failed’ state with result ‘exit-code’.
oct. 26 00:31:19 supervision systemd[1]: Failed to start The PHP 8.1 FastCGI Process Manager.

root@supervision:~# ps aux | grep php
root 437 0.0 0.7 222572 30904 ? Ss 00:25 0:00 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
librenms 521 0.0 0.3 222956 15556 ? S 00:25 0:00 php-fpm: pool librenms
librenms 522 0.0 0.4 222956 17336 ? S 00:25 0:00 php-fpm: pool librenms
librenms 4174 0.0 0.0 2484 572 ? S 00:35 0:00 /bin/sh -c /usr/bin/env php /opt/librenms/discovery.php -h 2
librenms 4176 23.0 1.6 139368 65544 ? S 00:35 0:00 php /opt/librenms/discovery.php -h 2
root 4293 0.0 0.0 6284 696 pts/0 S+ 00:35 0:00 grep php

apt remove php7.4-fpm

systemctl restart php8.1-fpm

Working again ! Thanks you @murrant

Small oops in the solution below is that I have to launch it every day :frowning:
composer dump-autoload

Wich OS do you use ?

Ubuntu 20.04.5 LTS 64bits

On my side i’m on debian 11.

For debian 11 i have updated like this:
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
apt update
apt install php8.1-{common,bcmath,bz2,intl,gd,mbstring,mysql,zip,cli,fpm,pdo,mbstring,curl,xml,imagick,tidy,xmlrpc,dev,imap,opcache,soap} -y

After that i have debug my php7.4-fpm issue that was always installed so i remove php7.4-fpm
i have removed composer also ( apt remove composer) and reinstall it like murrant suggested as librenms user:
./scripts/composer_wrapper.php install --no-dev

If it can help…

Hello,

Same problem with debian 11.
I have remove php7.4 and composer, and i run scripts composer_wrapper.

If i remove, php7.4, i have Bad gateway on my webgui.
I have php 8.1

root       42075  0.0  0.5 230188 34508 ?        Ss   17:08   0:00 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)

I dont understand…;