User talk:Musikolo

From ArchWiki

Workaround for KDE Breeze Dark theme

Hi Musikolo, Thanks for your reply. I've forget to post on your User talk:Musikolo page, Saturday night.. sorry about that! :(

Just a few notes: There are few things that need to improve (few typo's) and it would be better to post suggestions into Talk pages first.

Could you please post your suggestion into Talk:Firefox/Tweaks, since that would be the the correct section.

Thanks for your contributions (+ future).

Please don't forget to sign your post! Francoism (talk) 13:17, 5 November 2017 (UTC)Reply[reply]

occ doesn't read NEXTCLOUD_PHP_CONFIG anymore

I've been using NextCloud for years, but I recently installed nextcloud from scratch in my new home server. I followed the steps of the wiki include the use of a separate php.ini for occ and other components. However, I've noticed occ doesn't read NEXTCLOUD_PHP_CONFIG environment, as you can see below:

[root@MyPC ~]# sudo -u nextcloud echo $NEXTCLOUD_PHP_CONFIG
/etc/webapps/nextcloud/php.ini
[root@MyPC ~]# sudo -u nextcloud /usr/share/webapps/nextcloud/occ upgrade -v
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php:139
Stack trace:
#0 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
...etc...
#37 /usr/share/webapps/nextcloud/lib/base.php(1111): OC::init()
#38 /usr/share/webapps/nextcloud/console.php(48): require_once('...')
#39 /usr/share/webapps/nextcloud/occ(11): require_once('...')
#40 {main}
[root@MyPC ~]#

However, if manually force php to use the right php.ini file through the -c switch, everything works like a charm:

[root@MyPC ~]# sudo -u nextcloud php -c /etc/webapps/nextcloud/php.ini /usr/share/webapps/nextcloud/occ upgrade -v
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
2022-10-10T15:52:46+00:00 Setting log level to debug
2022-10-10T15:52:46+00:00 Turned on maintenance mode
2022-10-10T15:52:46+00:00 Repair step: Repair MySQL collation
2022-10-10T15:52:46+00:00 Repair info: All tables already have the correct collation -> nothing to do
2022-10-10T15:52:46+00:00 Repair step: Repair SQLite autoincrement
2022-10-10T15:52:46+00:00 Repair step: Copy data from accounts table when migrating from ownCloud
2022-10-10T15:52:47+00:00 Repair step: Drop account terms table when migrating from ownCloud
2022-10-10T15:52:47+00:00 Updating database schema
2022-10-10T15:52:47+00:00 Updated database
...etc...
2022-10-10T15:52:52+00:00 Starting code integrity check...
2022-10-10T15:53:21+00:00 Finished code integrity check
2022-10-10T15:53:21+00:00 Update successful
2022-10-10T15:53:21+00:00 Turned off maintenance mode

Is this issue caused because the NEXTCLOUD_PHP_CONFIG environment variable is no longer supported? Or is it because I'm doing something wrong? -- Musikolo (talk) 16:31, 10 October 2022 (UTC)Reply[reply]

/usr/bin/occ still takes NEXTCLOUD_PHP_CONFIG into account. Your issue is that user nextcloud doesn't have this environment variable set and sudo -u nextcloud by default doesn't forward environment variables from one user to the other.
Actually you don't have to explicitly use sudo -u nextcloud. Have a look at /usr/bin/occ. There you will see that sudo -u nextcloud is applied internally - together with the vital command line option --preserve-env. -- Wolegis (talk) 07:25, 11 October 2022 (UTC)Reply[reply]

I tried the following just to give another chance:

[root@MyPC ~]# sudo -u nextcloud sh
sh-5.1$ whoami
nextcloud

sh-5.1$ export NEXTCLOUD_PHP_CONFIG=/etc/webapps/nextcloud/php.ini

sh-5.1$ echo $NEXTCLOUD_PHP_CONFIG
/etc/webapps/nextcloud/php.ini

sh-5.1$ ls -l $NEXTCLOUD_PHP_CONFIG
-rw-r--r-- 1 nextcloud nextcloud 73019 Sep 29 10:33 /etc/webapps/nextcloud/php.ini

sh-5.1$ /usr/share/webapps/nextcloud/occ upgrade -v
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php:139
Stack trace:
#0 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /usr/share/webapps/nextcloud/lib/private/DB/Connection.php(261): Doctrine\DBAL\Connection->executeQuery()
#3 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /usr/share/webapps/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\DBAL\Query\QueryBuilder->execute()
...etc...
#37 /usr/share/webapps/nextcloud/lib/base.php(1111): OC::init()
#38 /usr/share/webapps/nextcloud/console.php(48): require_once('...')
#39 /usr/share/webapps/nextcloud/occ(11): require_once('...')
#40 {main}
sh-5.1$

However, if I do this right after, it just works!

sh-5.1$ php -c $NEXTCLOUD_PHP_CONFIG /usr/share/webapps/nextcloud/occ upgrade -v
Nextcloud is already latest version
sh-5.1$

I don't know what I'm wrong, but I don't a way to get the NEXTCLOUD_PHP_CONFIG variable used. -- Musikolo (talk) 16:03, 11 October 2022 (UTC)Reply[reply]

/usr/share/webapps/nextcloud/occ is the original CLI maintenance tool by Nextcloud upstream. It doesn't know anything about NEXTCLOUD_PHP_CONFIG. /usr/bin/occ is the wrapper script around this maintenance tool created by the maintainers of the Arch Linux Nextcloud package. The latter takes NEXTCLOUD_PHP_CONFIG into account (and some other env variables). So your fault was to start /usr/share/webapps/nextcloud/occ explicitly, instead of the wrapper script by just typing occ (i.e. without any path prefix).
BTW: occ upgrade is a VERY BAD IDEA. At best this will simply not work, at worst it will ruin your installation. Do any upgrade with pacman (or your preferred wrapper tool). -- Wolegis (talk) 07:25, 12 October 2022 (UTC)Reply[reply]
You're right, that was my mistake. I was using the upstream occ tool at /usr/share/webapps/nextcloud/occ instead of the Arch-provided wrapper at /usr/bin/occ. When I tried with the wrapper, everything worked nicely. I've been using the upstream tool for years and that's what it probably caused I didn't notice the difference.
I have another question based on your last comment about not using occ upgrade. I don't have any pacman hooks enabled, and I rather use occ by hand after each nextcloud update. I've been doing this for years, and I never run in to any sort of issues. Is there anything I should do differently? -- Musikolo (talk) 13:50, 12 October 2022 (UTC)Reply[reply]
I have to apologize. I messed up occ upgrade with the upgrade command of a another PHP based application that does in-place upgrading of the application itself. That (of course) conflicts with upgrading the application with pacman. -- Wolegis (talk) 14:03, 12 October 2022 (UTC)Reply[reply]
That makes sense. Thanks a lot for your help! ;-) -- Musikolo (talk) 14:10, 12 October 2022 (UTC)Reply[reply]