mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-04-26 09:46:00 +03:00
[GH-ISSUE #1910] [vaultwarden::db::sqlite_migrations][ERROR] Error creating database directory when using Postgres #1105
Labels
No labels
SSO
Third party
better for forum
bug
bug
documentation
duplicate
enhancement
future Vault
future Vault
future Vault
good first issue
help wanted
low priority
notes
pull-request
question
troubleshooting
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vaultwarden#1105
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cschmatzler on GitHub (Aug 16, 2021).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/1910
Subject of the issue
Using a
DATABASE_URLenv variable starting withpostgres://, Vaultwarden still tries to run SQLite migrations and fails at https://github.com/dani-garcia/vaultwarden/blob/main/src/db/mod.rs#L291. Data directory is writeable since the keys are created successfully.Deployment environment
Debian Bullseye with Docker
version 20.10.8, build 3967b7dvaultwarden version: Docker image
vaultwarden/server:1.22.2Install method:
MySQL/MariaDB or PostgreSQL version:
postgres:13.3Other relevant details:
env-vaultwarden:
Running it under root uid works.
Steps to reproduce
Create the env file, a postgres database, data dir with correct owner and run the above command to launch the docker image.
Expected behaviour
SQLite migrations should be skipped and container should launch.
Actual behaviour
Container stops at SQLite migrations failing
Troubleshooting data
@BlackDex commented on GitHub (Aug 16, 2021):
I'm having no issues using postgresql.
Are you sure the correct env is loaded? Since sqlite is default, i think those env's you try to load arn't working.
Try to add LOG_LEVEL=debug or trace and see if the output changes.
@cschmatzler commented on GitHub (Aug 16, 2021):
Running
Passing the
DATABASE_URLenvironment variable topsqlconnects to the database successfully.@cschmatzler commented on GitHub (Aug 16, 2021):
Let's minimize a little:
results in the same.
Omitting the
userflag and running it as root does start the container and logsRunning migrationa bunch, and brings up the web vault... but does not write anything to the Postgres database and loses all data after a container restart, so it's writing somewhere in the ephemeral file system.Which is very interesting, because it also logs
and if it was defaulting to sqlite...
https://github.com/dani-garcia/vaultwarden/blob/main/src/config.rs#L302
https://github.com/dani-garcia/vaultwarden/blob/main/src/config.rs#L314
are both using
c.data_folder, which has write permissions even for my1500:1500user, because thersa_keypath can be created and does persist between container restarts.@cschmatzler commented on GitHub (Aug 16, 2021):
Found the issue.
DATABASE_URLmay not be quoted, neither in single nor in double quotes. This is in contrast to the wiki entry here, which givesThe server should probably allow quoted environment variables? When passing a quoted variable as
-e DATABASE_URL='...', Docker automatically unquotes it, but as--env-file, it stays quoted.@jjlin commented on GitHub (Aug 16, 2021):
It's generally not the application's job to do more unquoting on environment variables, as the user might want an env var to have a quoted value. Unfortunately, there is not really any standard for env file syntax, so different tools can handle it differently.
I've updated https://github.com/dani-garcia/vaultwarden/wiki/Configuration-overview#loading-environment-variables-from-a-file to mention this pitfall with
--env-file. That wiki page covers other ways to load env files as well.email_token_sizesetting #2885