Error 500 when viewing invoices

Hello everybody

First post, hope this is the right place to put it.

I just did an install of v5.0.56-C40 following the guide on Ubuntu 20.04, lxc on proxmox.
Installation on local network, hostname is invoiceninja.

When viewing an invoice i get an error 500.

larval.log doesn’t mention any problems.
/var/log/nginx/ininja.access.log gives the following message:

[02/Feb/2021:12:03:26 +0000] "GET /client/invoice/RZZ4b3YntOjA2Nr6kfC69X2tIQZty6nTsdCWHilNbghGHfYaHxi7yiHSw2H5lMCR/download_pdf HTTP/2.0" 500 1558 "https://invoiceninja/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36"

During install, the PDF-test worked fine.
Could this be an nginx-misconfiguration ?

nginx is configured exactly like in the guide, except for the hostname.

Thanks in advance.

Hey there.

500 errors are usually written in laravel.log if not, it’s probably a permission problem.

Here’s how you can turn on in-browser errors (don’t forget to turn it off later because it might expose your credentials).

.env: APP_DEBUG=true (false should be default)

… and run the following:

php artisan optimize

Please let us know about the outcome.

Thanks for your reply.

APP_DEBUG is now set to true (Red notification showing in side bar)

This is the output from larval.log:

[2021-02-03 19:05:11] production.ERROR: The file "/usr/share/nginx/invoiceninja/public/storage/0BCQ5RYFejZn5pyTsGyln8mQOtdojNpYoEmqmMVmEaoFOsb3FNvZzj8tDMBY4p9P/swRGwM2TIuolL9CnRaO7EKAIyHnf8kxhzNFC7bi3/invoices/0002.pdf" does not exist {"exception":"[object] (Symfony\\Component\\HttpFoundation\\File\\Exception\\FileNotFoundException(code: 0): The file \"/usr/share/nginx/invoiceninja/public/storage/0BCQ5RYFejZn5pyTsGyln8mQOtdojNpYoEmqmMVmEaoFOsb3FNvZzj8tDMBY4p9P/swRGwM2TIuolL9CnRaO7EKAIyHnf8kxhzNFC7bi3/invoices/0002.pdf\" does not exist at /usr/share/nginx/invoiceninja/vendor/symfony/http-foundation/File/File.php:36)
[stacktrace] 
<stacktrace continues>

The contents of ./public/storage is indeed empty:

ls -l public/storage/
total 936
-rw-rw-r-- 1 www-data www-data 956852 Feb  1 19:07 test.pdf

Permissions on the folders are as follows:

ls -l public/
total 12656
drwxr-sr-x 6 www-data www-data    4096 Jan 29 13:06 assets
drwxr-sr-x 2 www-data www-data    4096 Jan 29 13:07 css
-rwxr-sr-x 1 www-data www-data   15086 Jan 29 13:06 favicon.ico
-rwxr-sr-x 1 www-data www-data    2700 Jan 29 13:06 favicon.png
-rwxr-sr-x 1 www-data www-data    8120 Jan 29 13:06 flutter_service_worker.js
drwxr-sr-x 2 www-data www-data    4096 Jan 29 13:06 icons
drwxr-sr-x 3 www-data www-data    4096 Jan 29 13:06 images
-rwxr-sr-x 1 www-data www-data    1850 Jan 29 13:06 index.php
drwxr-sr-x 5 www-data www-data    4096 Jan 29 13:06 js
-rwxr-sr-x 1 www-data www-data 7773353 Jan 29 13:06 main.dart.js
-rwxr-sr-x 1 www-data www-data 5100101 Jan 29 13:06 main.dart.js.map
-rwxr-sr-x 1 www-data www-data     797 Jan 29 13:06 manifest.json
-rwxr-sr-x 1 www-data www-data    1851 Jan 29 13:07 mix-manifest.json
-rwxr-sr-x 1 www-data www-data      24 Jan 29 13:06 robots.txt
drwxrwsr-x 2 www-data www-data    4096 Feb  1 19:02 storage
drwxr-sr-x 2 www-data www-data    4096 Jan 29 13:06 svg
drwxr-sr-x 4 www-data www-data    4096 Jan 29 13:06 vendor
-rwxr-sr-x 1 www-data www-data      74 Jan 29 13:06 version.json

I hope this helps.

I enabled the expanded logging and got the following error message:

[2021-02-04 19:04:42] production.INFO: The command "'/usr/share/nginx/invoiceninja/vendor/beganovich/snappdf/versions/848474-Linux_x64/chrome-linux/chrome' '--headless' '--disable-gpu' '--disable-translate' '--disable-extensions' '--disable-sync' '--disable-background-networking' '--disable-software-rasterizer' '--disable-default-apps' '--disable-dev-shm-usage' '--safebrowsing-disable-auto-update' '--run-all-compositor-stages-before-draw' '--no-first-run' '--no-margins' '--no-sandbox' '--print-to-pdf-no-header' '--hide-scrollbars' '--print-to-pdf=/tmp/pdf_1ihAPQ.pdf' '/tmp/html_mWsupQ.html'" failed.

Exit Code: 127(Command not found)

Working directory: /usr/share/nginx/invoiceninja/public

Output:
================


Error Output:
================
/usr/share/nginx/invoiceninja/vendor/beganovich/snappdf/versions/848474-Linux_x64/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory

It looks like i’m missing something in my installation.
Does anybody know how which dependency this may be part of ?

Found the solution.
I was missing libgbm-dev.

apt install libgbm-dev

did the trick.

3 Likes

How did you enable the expanded logging?

I added EXPANDED_LOGGING=true to the .env file and ran php artisan optimize afterwards.

1 Like

Thanks! Now I have an error message with a little bit more detail, but I don’t know how to fix it :frowning:

[2021-02-07 14:10:19] production.INFO: The command "'/var/www/html/ninja/vendor/beganovich/snappdf/versions/850397-Linux_x64/chrome-linux/chrome' '--headless' '--disable-gpu' '--disable-translate' '--disable-extensions' '--disable-sync' '--disable-background-networking' '--disable-software-rasterizer' '--disable-default-apps' '--disable-dev-shm-usage' '--safebrowsing-disable-auto-update' '--run-all-compositor-stages-before-draw' '--no-first-run' '--no-margins' '--no-sandbox' '--print-to-pdf-no-header' '--hide-scrollbars' '--print-to-pdf=/tmp/pdf_6Gek1B.pdf' '/tmp/html_pkHhmC.html'" failed.

Exit Code: 2(Misuse of shell builtins)

Working directory: /var/www/html/ninja/public

Output:
================


Error Output:
================
sh: 1: exec: /var/www/html/ninja/vendor/beganovich/snappdf/versions/850397-Linux_x64/chrome-linux/chrome: Exec format error

Well actually I have an idea. It says x64, but I have an x86 installation…I guess that is the problem…

Hey there, that could be a problem, definitely. You may want to provide your own Chrome/Chromium installed on your machine.

Then, provide globally available environment variable (not .env file):

SNAPPDF_EXECUTABLE_PATH=/path/to/your/chrome

If that works, please let me know, I’ll file a bug report on the snappdf repository & check 32bit compatibility. It should be supported as well :+1: