NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.95k stars 13.97k forks source link

Firefly III: fails while upgrading the system in firefly-iii-maintenance.sh #344821

Closed rkunschke closed 3 weeks ago

rkunschke commented 3 weeks ago

Describe the bug

I've notices the update on my server failing and firefly III seems to be the reason.. I've looked up the problem with journalctl and got that log:

Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12016]:   10  app/Exceptions/Handler.php:234
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12016]:       FireflyIII\Jobs\MailError::__construct(["unknown@example.com"], "", "127.0.0.1")
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:    UnexpectedValueException
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:   There is no existing directory at "/nix/store/l559364qmlqhd1yc7r6b8lfr6nzyvskv-firefly-iii-6.1.19/storage/logs" and it could not be crea>
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:   at vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:205
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     201▕             });
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     202▕             $status = mkdir($dir, 0777, true);
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     203▕             restore_error_handler();
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     204▕             if (false === $status && !is_dir($dir) && strpos((string) $this->errorMessage, 'File exists') === false) {
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:   ➜ 205▕                 throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and it could not be created: >
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     206▕             }
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     207▕         }
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     208▕         $this->dirCreated = true;
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:     209▕     }
Sep 27 08:10:36 mydomain rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh[12031]:       +8 vendor frames 

I opended up the firefly-iii-maintenance.sh and noticed the paths used in that sh-file seem to refer to an older nix store path of firefly which is not present.

I am unable to rebuild my system and found no way too work around that issue.

Notify maintainers

@savyajha @PatrickDaG

Metadata

this path will be fetched (0.02 MiB download, 0.06 MiB unpacked):
  /nix/store/91d27rjqlhkzx7mhzxrir1jcr40nyc7p-stdenv-linux
copying path '/nix/store/91d27rjqlhkzx7mhzxrir1jcr40nyc7p-stdenv-linux' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.52, NixOS, 24.11 (Vicuna), 24.11.20240923.30439d9`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.7`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/store/p2hby44a0qzrnd1vxcpcgfav6160rmcv-source`
savyajha commented 3 weeks ago

@rkunschke Could you try removing /var/lib/firefly-iii/cache/config.php and retrying?

savyajha commented 3 weeks ago

Also, could you paste the contents of rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh here?

rkunschke commented 3 weeks ago

@savyajha Oh that was a quick answer, thank you :) removing the config.php in the cache directory fixed my issue. Firefly is running again :) the file is gone now (rld865prwn8v8r1yiz7xpkvgz5d70sgl-firefly-iii-maintenance.sh) but I looked it up at it's new directory (/nix/store/bmp10c984wa3d9bnayiz6hfj9266p9xy-firefly-iii-maintenance.sh):

#!/nix/store/izpf49b74i15pcr9708s3xdwyqs4jxwl-bash-5.2p32/bin/bash
set -a
APP_ENV=local
APP_URL=...
DB_CONNECTION=sqlite
DB_HOST=localhost
.... private mail config ....
APP_KEY="$(< /nix/store/x1x61bfvsjg9lzbclzid9fhybw5gybqx-keyfile)"

set +a

touch /var/lib/firefly-iii/storage/database/database.sqlite
/nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan cache:clear
/nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan package:discover
/nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan firefly-iii:upgrade-database
/nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan firefly-iii:laravel-passport-keys
/nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan view:cache
/nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan route:cache
/nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan config:cache

seems like the path of the maintainance.sh differs to the nix store paths in the bash-script as well. But I didn't fully understood that nix store-path things ever. Looks good for me now. Should we close the issue or try to find out why that happened?

rkunschke commented 3 weeks ago

Maybe it would be useful to make that cache-file automatically removed while upgrading firefly?

savyajha commented 3 weeks ago

So /nix/store/86r39ckr1y52v7zs2ikcf6l2knr7xasy-firefly-iii-6.1.19/artisan cache:clear is supposed to do that. In fact, if you run the command, config.php should disappear. I do not know why it sometimes fails. If we get another bug report on this same issue sometime again, I'll make the change.

Also, were you upgrading to 6.1.19 from something like 6.1.15? I remember I moved the cache clear command to the very top around that time.

rkunschke commented 3 weeks ago

Ah okay. It's possible I missed that update since then. I think my auto-upgrade service failed for some time. I don't check my server that often. I should enable a mail notification for failing services because that seems to be kind of dangerous 😆

kai-tub commented 2 weeks ago

Hey :wave:

I had the same issue.

Could you try removing /var/lib/firefly-iii/cache/config.php and retrying?

Fixed it for me as well.

I've updated from:

[U.]  #015  firefly-iii 6.1.19, 6.1.19-composer-repository -> 6.1.21, 6.1.21-composer-repository
savyajha commented 2 weeks ago

Cool. For the next upgrade I'll just add this to the maintainer script.