Repository navigation
Description
The update the Nextcloud 35.0.1 on my server failed, since I had the PHP iconv module disabled. I needed to enable it to proceed with updater.phar:
========================
> Using PHP 8.4.24
> PHP is using the following php.ini file:
/etc/php/8.4/cli/php.ini
> Checking Box requirements:
.........E.
[ERROR] Your system is not ready to run the application.
Fix the following mandatory requirements:
=========================================
* The package "symfony/polyfill-mbstring" requires the extension "iconv". You either need to enable it or request the application to be shipped with a polyfill for this extension.
The source code of this polyfill indicates and shows that it uses iconv for its base functionality:
Partial mbstring implementation in PHP, iconv based, UTF-8 centric.
Two modules on my Nextcloud ship symfony/polyfull-mbstring:
/var/www/nextcloud/apps/dav_push/vendor/symfony/polyfill-mbstring
/var/www/nextcloud/apps/suspicious_login/vendor/symfony/polyfill-mbstring
But there is a much larger number of apps depending on this, or on the iconv extension directly: https://github.com/search?q=org%3Anextcloud+%2Fext-iconv%2F&type=code
The documentation does not mention iconv yet, so I'd add it here: https://docs.nextcloud.com/server/stable/admin_manual/installation/php_configuration.html#php-modules-for-specific-applications
However, I saw these PRs:
And then I found this: https://github.com/nextcloud/3rdparty/blob/master/composer.json#L83
"replace": { "paragonie/random_compat": "*", "symfony/polyfill-php80": "*", "symfony/polyfill-php81": "*", "symfony/polyfill-php82": "*", "symfony/polyfill-php83": "*", "symfony/polyfill-ctype": "*", "symfony/polyfill-mbstring": "*" },
Do I understand it right, that since Nextcloud's own 3rd party dependencies provide/replace this polyfill (as it explicitly depends on ext-mbstring, like on ext-ctype and PHP >=8.3), no app would actually require it, when expecting nextcloud/3rdparty to be present for dependency resolving? Maybe a bunch of unnecessary dependencies and polyfill could be dropped from many Nextcloud apps, by adjusting their build environments accordingly?
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriaged
Activity
susnux commentedon Oct 6, 2026
Yes the
mbstringextension is mandatory for every Nextcloud installation, seehttps://docs.nextcloud.com/server/stable/admin_manual/installation/php_configuration.html#required-php-modules
Thats why 3rdparty does explicitly disable that dependency to not install useless polyfills
MichaIng commentedon Oct 6, 2026
I guess a package like
symfony/polyfill-mbstringcannot declare on its own that it is needed only ifmbstring/ext-mbstringis not present/fulfilled already, which would be the cleanest solution for the PHP ecosystem."replace"can do this on project-level, but it works only if this project is pulled into the environment already.For app devs, it is not handy to maintain a copy of
3rdparty'sreplacelist. Of course they could pull in3rdpartyas dependency for the app by default, but that seems inaccurate, and the project is not atpackagist.org, only an old fork: https://packagist.org/packages/kesselb/nextcloud-3rdpartyI am not a composer-expert, but maybe there is a simple way to take the
replaces from the target Nextcloud version's 3rdparty as fulfilled, without pulling in the whole 3rdparty as dependency into the environment 🤔. If we can get rid of a potentially large number of duplicate and unnecessary polyfills and their dependencies bundled and loaded with Nextcloud apps, and reduce additional PHP modules pulled in by apps' dependency tails, that would be great.EDIT: Ah wait, actually https://packagist.org/packages/kesselb/nextcloud-3rdparty is a meta package for exactly that purpose: Fulfilling the 3rdparty's dependencies in other projects with the full
replaceslist, without any actual data, just to satisfy composer with what Nextcloud ships anyway. @kesselb did I get this right? How does it work with dependencies that are actually required to build the app? There does not seem to be areplace-dev, soreplaceapplies forrequire-devtoo, which could cause issues in practice? But having such up-to-date, and dedicated packages for all supported Nextcloud versions, seems to be a good approach to avoid unnecessary runtime dependencies in apps.susnux commentedon Oct 6, 2026
Well its not needed, the polyfill is only used when needed (it autodetects if mbstring is available).
Why should there be any "build time"? Any dev dependency should not be in your composer.json but in some vendor-bin to not pollute the global namespace, as such you will have them in the dev dependencies but in vendor-bin where it will not be shipped (e.g. only for linting or testing).
See also https://docs.nextcloud.com/server/latest/developer_manual/app_development/dependency_management.html#dependency-hell
MichaIng commentedon Oct 6, 2026
Right, it does not get loaded at runtime, which my OPcache content also shows. But the polyfill and all its dependencies is unnecessary data in the app package. And its PHP module dependencies are enforced for Nextcloud, as the error message shows, and this did cause a mid-upgrade crash in my case. EDIT: Although not 100% sure whether the NC upgrade crashed for the same reason for which
updater.pharcould not continue it. I started it from the web UI, and there were zero logs about the crash/error, it just stopped while moving files in place with some generic error, throwing a 500 on retry.Ah right, then this part is not an issue.
kesselb commentedon Oct 6, 2026
The idea of nextcloud-3rdparty was indeed to provide a virtual package that apps can require in composer.json to avoid installing packages which are part of nextcloud itself. I hit some road blocker's back then and never finished it.
MichaIng commentedon Oct 6, 2026
Which blockers were those?
I mean, it is nothing urgent or important, since
iconvwill be available and enabled in most Nextcloud PHP instances anyway. So it was mostly me actively disabling anything that I did not find necessary, either from docs or own tests/findings.And checking back at GitHub search query for iconv dependents, most have this in
vendor-bin, resp. viarequire-devinpackages-devonly, and the few remaining ones, which really require it at runtime, do so with the verysymfony/polyfill-mbstringdependency. So it is probably sufficient to address this particular case with areplaceat per-app level.But I am happy to have another look at some generic solution, too, learning more about composer in turn. And if there is a way with some meta package, a GitHub workflow to trigger a build on Nextcloud release tag pushes, or so. Maybe something to finish during NextConf27 contributors week 🙂.