Cannot update system because pdf is not writable

Update Available

A new version of the web app is available

  • Current Version: v5.3.15
  • Latest Version: v5.3.18

When I click on UPDATE NOW, I enter my password. Update fails with error message

“Cannot update system because R0008.pdf is not writable”

Laravel.log doesn’t show anything. I’m running Debian 9. installed V5 from invoiceninja.zip download on my own VPS server.

HI,

It looks like a permissions issue, the files need to be writeable by the www user to run the update.

Thanks for the answer. What are the steps or commands to update app to newest version using “root” access?

This is the command to update the permissions:

sudo chown -R www-data:www-data /var/www/html

From: Free Source Available Invoicing, Expenses & Time-Tracking | Invoice Ninja

Thanks! I wanted the know correct command to install the update not to change permission. Is it possible to update app using ROOT access?

Not sure that’s possible

Current Version: v5.3.15
Latest Version: v5.3.19

I get SERVER ERROR

Application does not work if I change permission to “www-data:www-data”.
I have my own server and full access.
Any other ways to update to latest version?

@anristudio The working directory where the Invoice Ninja files are at, what are the permissions set to?

For example, if I have all my Invoice Ninja files located at /var/www/html/invoiceninja/ the permissions would need to be set there and for the sub directories under it. You can see the owner and permissions set by using the list command

ls -la /var/www/html/invoiceninja/

To set the permissions correctly first I take ownership of the directory and the sub directories under it with the CHOWN command for the www-data owner and www-data group

sudo chown -R www-data:www-data /var/www/html/invoiceninja/

Then set the permissions for the directory and sub directories using the CHMOD command

sudo chmod -R 755 /var/www/html/invoiceninja/

When completed the permissions will be set correctly and using the list command again should look like this

──╼ $ls -la /var/www/html/invoiceninja/
total 1280
drwxr-xr-x 14 www-data www-data   4096 Jul 21 15:44 .
drwxr-xr-x  3 root     root       4096 Jun  2 11:05 ..
drwxr-xr-x 27 www-data www-data   4096 Aug 31 20:39 app
-rwxr-xr-x  1 www-data www-data   1686 Oct  5 17:39 artisan
-rwxr-xr-x  1 www-data www-data     63 Oct  5 17:39 .babelrc
drwxr-xr-x  3 www-data www-data   4096 May 12 05:02 bootstrap
-rwxr-xr-x  1 www-data www-data   2008 May 12 05:02 CHANGELOG.md
-rwxr-xr-x  1 www-data www-data     99 Oct  5 17:39 .codacy.yml
-rwxr-xr-x  1 www-data www-data     55 Oct  5 17:39 codecov.yml
-rwxr-xr-x  1 www-data www-data    358 Oct  5 17:39 CODE_OF_CONDUCT.md
-rwxr-xr-x  1 www-data www-data   4912 Oct  5 17:39 composer.json
-rwxr-xr-x  1 www-data www-data   4412 Jun  3 00:54 composer.json.oem.bak
-rwxr-xr-x  1 www-data www-data 582225 Oct  5 17:39 composer.lock
-rwxr-xr-x  1 www-data www-data  58460 May 21 12:23 composer-setup.php
drwxr-xr-x  2 www-data www-data   4096 Sep 10 08:31 config
drwxr-xr-x  7 www-data www-data   4096 May 12 05:02 cypress
-rwxr-xr-x  1 www-data www-data    209 Jul  6 04:10 cypress.json
drwxr-xr-x  6 www-data www-data   4096 May 12 05:02 database

Final step is to run the artisan optimize command from the Invoice Ninja working directory as the www-data user

Go to the directory
cd /var/www/html/invoiceninja/

Run the command from the directory as the www-data user
sudo -u www-data php artisan optimize

1 Like

@amp51 thank you! I did what you said, application does not work, browser has blank page/white page. I have to grant ownership from www-data:www-data to web1:client1 for app to work. I created website under subfolder of main website (works as subdomain - https://billing2.domain.com) on my server with user web1:client1, this user has access to do everything that’s needed for subdomain website. I installed app without any issues, without changing any permissions or ownership. According to apache error log (below), I don’t think updating of the app is permission issue in my case. There are PHP fatal error issues. Here’s my info

ls -la
total 1168
drwxr-xr-x 13 www-data www-data 4096 Sep 27 19:03 .
drwx–x–x 19 web1 client1 4096 Oct 4 11:31 …
-rwxr-xr-x 1 www-data www-data 63 Sep 17 05:52 .babelrc
-rwxr-xr-x 1 www-data www-data 99 Sep 17 05:52 .codacy.yml
-rwxr-xr-x 1 www-data www-data 213 Sep 17 05:52 .editorconfig
-rwxr-xr-x 1 www-data www-data 1265 Oct 2 00:54 .env
-rwxr-xr-x 1 www-data www-data 499 Sep 17 05:52 .env.ci
-rwxr-xr-x 1 www-data www-data 484 Sep 17 05:52 .env.dusk.example
-rwxr-xr-x 1 www-data www-data 1066 Sep 17 05:52 .env.example
-rwxr-xr-x 1 www-data www-data 461 Sep 17 05:52 .env.travis
-rwxr-xr-x 1 www-data www-data 111 Sep 17 05:52 .gitattributes
-rwxr-xr-x 1 www-data www-data 418 Sep 17 05:52 .gitignore
-rwxr-xr-x 1 www-data www-data 6067 Sep 17 05:52 .htaccess
-rwxr-xr-x 1 www-data www-data 488 Sep 17 05:52 .php_cs
-rwxr-xr-x 1 www-data www-data 103 Sep 17 05:52 .prettierrc
-rwxr-xr-x 1 www-data www-data 358 Sep 17 05:52 CODE_OF_CONDUCT.md
-rwxr-xr-x 1 www-data www-data 3891 Sep 17 05:52 LICENSE
-rwxr-xr-x 1 www-data www-data 4777 Sep 17 05:52 README.md
-rwxr-xr-x 1 www-data www-data 6 Sep 17 05:52 VERSION.txt
drwxr-xr-x 27 www-data www-data 4096 Sep 17 05:52 app
-rwxr-xr-x 1 www-data www-data 1686 Sep 17 05:52 artisan
drwxr-xr-x 3 www-data www-data 4096 Sep 17 05:52 bootstrap
-rwxr-xr-x 1 www-data www-data 55 Sep 17 05:52 codecov.yml
-rwxr-xr-x 1 www-data www-data 4827 Sep 17 05:52 composer.json
-rwxr-xr-x 1 www-data www-data 573422 Sep 17 05:52 composer.lock
drwxr-xr-x 2 www-data www-data 4096 Sep 17 05:52 config
drwxr-xr-x 6 www-data www-data 4096 Sep 17 05:52 database
-rwxr-xr-x 1 www-data www-data 1703 Sep 17 05:52 dusk.sh
-rwxr-xr-x 1 www-data www-data 21 Sep 17 05:52 modules_statuses.json
-rwxr-xr-x 1 www-data www-data 439103 Sep 17 05:52 package-lock.json
-rwxr-xr-x 1 www-data www-data 1471 Sep 17 05:52 package.json
-rwxr-xr-x 1 www-data www-data 1295 Sep 17 05:52 phpunit.xml
-rwxr-xr-x 1 www-data www-data 2064 Sep 17 05:52 psalm.xml
drwxr-xr-x 10 www-data www-data 4096 Sep 26 22:56 public
drwxr-xr-x 6 www-data www-data 4096 Sep 17 05:52 resources
drwxr-xr-x 2 www-data www-data 4096 Sep 17 05:52 routes
-rwxr-xr-x 1 www-data www-data 563 Sep 17 05:52 server.php
drwxr-xr-x 3 www-data www-data 4096 Oct 5 19:02 stats
drwxr-xr-x 5 www-data www-data 4096 Sep 17 05:52 storage
-rwxr-xr-x 1 www-data www-data 714 Sep 17 05:52 tailwind.config.js
drwxr-xr-x 7 www-data www-data 4096 Sep 17 05:52 tests
drwxr-xr-x 82 www-data www-data 4096 Sep 17 05:53 vendor
-rwxr-xr-x 1 www-data www-data 3541 Sep 17 05:52 webpack.mix.js

Error log
AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught ErrorException: file_put_contents(/var/www/clients/client1/web1/web/billing2/storage/framework/views/08f16282bca0bdea83fbf05839ebcce7f930a10d.php): failed to open stream: Permission denied in /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:187\nStack trace:\n#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()\n#1 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(187): file_put_contents()\n#2 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(163): Illuminate\Filesystem\Filesystem->put()\n#3 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(55): Illuminate\View\Compilers\BladeCompiler->compile()\n#4 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/Vie…PHP message: PHP Fatal error: Uncaught ErrorException: file_put_contents(/var/www/clients/client1/web1/web/billing2/storage/framework/views/08f16282bca0bdea83fbf05839ebcce7f930a10d.php): failed to open stream: Permission denied in /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:187\nStack trace:\n#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()\n#1 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(187): file_put_contents()\n#2 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(163): Illuminate\Filesystem\Filesystem->put()\n#3 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(55): Illuminate\View\Compilers\BladeCompiler->compile()\n#4 /var/www/clients/client1/web1/web/billing2/vendor/laravel/framework/src/Illuminate/Vie…’

I’d appreciate any other ideas, and thanks in advance for any help.

@anristudio Have seen similar errors but need to get more info from you about the environment this instance is running on. Off the top, without knowing more about your environment, it seems the issue is with configuration and\or permissions.

Hers’s what I think I know about your install, correct whatever is needs to be corrected

  • VPS based on Debian 9
  • Is the VPS shared with other users\applications (installed on this instance)?
  • Does this VPS use containers such as Docker?

Here’s the other stuff I need to know

  • Did Invoice Ninja ever work before this update or is this a new or relatively new install?
  • Is this system in production?
  • What version of PHP is being used by Invoice Ninja?
  • It is possible to have multiple apps hosted on a VPS instance using different version of PHP
  • What web engine is being used by Invoice Ninja (Apache, NGINX, etc)?
  • What database engine is being used by Invoice Ninja (Postgre, MySQL, MariaDB, etc)?
  • Is the database on (installed) the local VPS instance or is it using a remote database (SQL server)?
  • At the time of setup, was Invoice Ninja configured to use SnapPDF or PhantomJS?
  • At the first time run of Invoice Ninja did you get the first time setup screen (see screenshot below)
  • Were you able to successfully complete the first time run setup?

First time setup screenshot

@amp51 thanks for your help, please see my answers below

VPS based on Debian 9: YES
Is the VPS shared with other users\applications (installed on this instance)? NO
Does this VPS use containers such as Docker? NO

Here’s the other stuff I need to know

Did Invoice Ninja ever work before this update or is this a new or relatively new install? YES  I initially installed v5.3.15-C59 w/o issues - works now, I just cannot update, using update feature within app.
Is this system in production? YES
What version of PHP is being used by Invoice Ninja? PHP 7.4
It is possible to have multiple apps hosted on a VPS instance using different version of PHP: YES
What web engine is being used by Invoice Ninja (Apache, NGINX, etc)? APACHE
What database engine is being used by Invoice Ninja (Postgre, MySQL, MariaDB, etc)?  MariaDB
Is the database on (installed) the local VPS instance or is it using a remote database (SQL server)? Local VPS instance
At the time of setup, was Invoice Ninja configured to use SnapPDF or PhantomJS? I think PhantomJS
At the first time run of Invoice Ninja did you get the first time setup screen (see screenshot below) YES
Were you able to successfully complete the first time run setup? YES

Invoice Ninja update v5.3.19 was pulled due to an issue. Other updates have been released, can you try to apply one of those?

Selection_318

Same issue as my post #1

“Cannot update system because R0041.pdf is not writable”

Again, this is not a permission nor ownership issue as I was able to install app.