You are not logged in.

#1 2020-08-18 23:16:35

Smith oo4
Member
From: Calgary, Alberta, Canada
Registered: 2007-12-30
Posts: 35

Grocy Slim Application Error

I am trying to run Grocy, however when I point a browser at the machine I installed it on I get the following error:

Slim Application Error
The application could not run because of the following error:
Details
Type: PDOException
Code: 14
Message: SQLSTATE[HY000] [14] unable to open database file
File: /usr/share/webapps/grocy/services/DatabaseService.php
Line: 39
Trace
#0 /usr/share/webapps/grocy/services/DatabaseService.php(39): PDO->__construct()
#1 /usr/share/webapps/grocy/services/DatabaseService.php(66): Grocy\Services\DatabaseService->GetDbConnectionRaw()
#2 /usr/share/webapps/grocy/services/DatabaseMigrationService.php(9): Grocy\Services\DatabaseService->ExecuteDbStatement()
#3 /usr/share/webapps/grocy/controllers/SystemController.php(20): Grocy\Services\DatabaseMigrationService->MigrateDatabase()
#4 /usr/share/webapps/grocy/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(43): Grocy\Controllers\SystemController->Root()
#5 /usr/share/webapps/grocy/vendor/slim/slim/Slim/Routing/Route.php(381): Slim\Handlers\Strategies\RequestResponse->__invoke()
#6 /usr/share/webapps/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\Routing\Route->handle()
#7 /usr/share/webapps/grocy/middleware/SessionAuthMiddleware.php(35): Slim\MiddlewareDispatcher->handle()
#8 /usr/share/webapps/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(283): Grocy\Middleware\SessionAuthMiddleware->__invoke()
#9 /usr/share/webapps/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): class@anonymous->handle()
#10 /usr/share/webapps/grocy/vendor/slim/slim/Slim/Routing/Route.php(341): Slim\MiddlewareDispatcher->handle()
#11 /usr/share/webapps/grocy/vendor/slim/slim/Slim/Routing/RouteRunner.php(84): Slim\Routing\Route->run()
#12 /usr/share/webapps/grocy/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(60): Slim\Routing\RouteRunner->handle()
#13 /usr/share/webapps/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(140): Slim\Middleware\RoutingMiddleware->process()
#14 /usr/share/webapps/grocy/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(107): class@anonymous->handle()
#15 /usr/share/webapps/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(140): Slim\Middleware\ErrorMiddleware->process()
#16 /usr/share/webapps/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): class@anonymous->handle()
#17 /usr/share/webapps/grocy/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle()
#18 /usr/share/webapps/grocy/vendor/slim/slim/Slim/App.php(199): Slim\App->handle()
#19 /usr/share/webapps/grocy/app.php(68): Slim\App->run()
#20 /usr/share/webapps/grocy/public/index.php(27): require_once('/usr/share/weba...')
#21 {main}

I have installed this on a freshly installed Arch Linux VM using PHP-FPM and Caddy V1 web server. Below are the instructions I followed:


yay -Syu caddy sqlite php php-fpm php-sqlite php-gd grocy

sudo sed -i 's/;extension=pdo_sqlite/extension=pdo_sqlite/g' /etc/php/php.ini
sudo sed -i 's/;extension=sqlite3/extension=sqlite3/g' /etc/php/php.ini
sudo sed -i 's/;extension=gd/extension=gd/g' /etc/php/php.ini

sudo systemctl start php-fpm
sudo systemctl enable php-fpm
sudo systemctl status php-fpm

sudo nano /etc/caddy/conf.d/grocy.conf 

:9283 {
        gzip
        errors /var/log/caddy/grocy_error.log
        root /usr/share/webapps/grocy/public
            fastcgi / unix:/run/php-fpm/php-fpm.sock php {
                index index.php
        }
}

sudo systemctl enable caddy
sudo systemctl start caddy
sudo systemctl status caddy

I have tried installing using NGINX instead of caddy as well as manually downloading the latest Grocy release, extracting, copying the confing file, changing permissions, etc. instead of using the AUR package as well. I have checked the permission of the ‘data’ folder in the Grocy install, (where the app saves its database) and it looks correct to me; “drwxr-xr-x 1 http root”. I have gone as far as to chmod -R 0777 the Grocy install. I have tried installing on an Arch derivative (Endeavouros and Manjaro) incase I screwed up the os install. In all case I have got the same error. I can get Grocy running on Fedora or FreeBSD so I think it must be something related to Arch Linux or my ability to uses it.

Any suggestions on how to fix or troubleshoot this?

Thank you

Last edited by Smith oo4 (2020-08-19 13:07:37)

Offline

#2 2020-08-19 01:29:53

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 17,458

Re: Grocy Slim Application Error

Moving to AUR issues.

Please edit your post and fix it to use BBCode Code tags around all program output and file contents.  And, only use quote tags for quotes.
Thanks


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2020-10-09 20:33:28

Gatgeagent
Member
Registered: 2020-10-09
Posts: 1

Re: Grocy Slim Application Error

Hi Smith!

I was pretty displeased having one of these super weird errors too (I've just had this issue and have not found the anwer online after at least ~40 min of searching), until I've remembered the weird php-fpm service file, in which one has to state all the paths that php is supposed to also be able to write to. I've troubledshooted this by creating the file with "touch" and being able to work with "sqlite3 grocy.db" in the "/usr/share/webapps/grocy/data" directory just fine.

The fix to make the directory writeable for php is to add the "/usr/share/webapps/grocy/data" directory to the php-fpm.service unit file:

systemctl edit php-fpm.service
[Service]
ReadWritePaths = /usr/share/webapps/grocy/data

Of course you have to make sure that your executing webserver user actually has permissions to the"usr/share/webapps/grocy/data" directory and "/usr/share/webapps/grocy/data/grocy.db" file, no idea about caddy but with a standard nginx/php-fpm configuration the user is "http", thus running

chown -R http:http /usr/share/webapps/grocy/data

does the trick for that.

Cheers!

Offline

Board footer

Powered by FluxBB