mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-04-26 09:46:00 +03:00
[GH-ISSUE #1060] .env file seems to be ignored? #749
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#749
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 @pdarcos on GitHub (Jul 20, 2020).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/1060
Hi everyone,
I recently recompiled bitwarden_rs after a fresh git clone and for some reason (likely a stupid mistake on my part) it seems the .env file isn't being parsed when I run ./bitwarden_rs from the target/release/ directory after it compiled.
I can see the .env file is in the same directory but bitwarden_rs doesn't seem to be reading it when it starts since it complains about the "missing" mysql configuration (which is there).
If I start bitwarden_rs with that config explicitly set in the command line it runs as expected which leaves me confused as to why it's not picking up the environment variables from it.
Do I need to run any command or any special permissions for bitwarden_rs to use the .env file that I placed in the release directory?
Thanks
~/bitwarden_rs/target/release# ls -la
total 24164
drwxr-xr-x 8 root root 4096 Jul 20 18:58 .
drwxr-xr-x 3 root root 4096 Jul 20 17:15 ..
-rwxr-xr-x 2 root root 24591112 Jul 20 17:15 bitwarden_rs
-rw-r--r-- 1 root root 5847 Jul 20 17:15 bitwarden_rs.d
drwxr-xr-x 102 root root 4096 Jul 20 17:03 build
-rw-r--r-- 1 root root 0 Jul 20 17:03 .cargo-lock
drwxr-xr-x 3 root root 4096 Jul 20 18:47 data
drwxr-xr-x 2 root root 69632 Jul 20 17:15 deps
-rw-r--r-- 1 root root 8507 Jul 20 18:58 .env
-rw-r--r-- 1 root root 8507 Jul 20 18:58 .env.template
drwxr-xr-x 2 root root 4096 Jul 20 17:03 examples
drwxr-xr-x 392 root root 20480 Jul 20 17:03 .fingerprint
drwxr-xr-x 2 root root 4096 Jul 20 17:03 incremental
@jjlin commented on GitHub (Jul 21, 2020):
It should work as long as
.envis in your current working directory. Runstrace -e trace=file ./bitwarden_rsand see whether.envis being read and what the result is.@pdarcos commented on GitHub (Jul 21, 2020):
Thanks @jjlin
I tried as you suggested but it doesn't seem to recognize the settings in the .env file even though it appears to open it without problems:
strace -e trace=file ./bitwarden_rsopenat(AT_FDCWD, ".env", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "data/config.json", O_RDONLY|O_CLOEXEC) = 3
Error loading config:
DATABASE_URLshould start with mysql: when using the MySQL server+++ exited with 12 +++
root@vault:~/bitwarden_rs/target/release#
cat .envDATABASE_URL=mysql://bitwarden_rs:mysecretpassword@localhost:3306/bitwarden_rs
The DATABASE_URL is set to the correct format in the .env file as you can see above. But for some reason bitwarden_rs doesn't seem to recognize it.
Any ideas?
Thanks
@pdarcos commented on GitHub (Jul 22, 2020):
Anyone have any ideas? Is this just happening to me?
Do I have to recompile bitwarden_rs with the .env file in the source directory? That doesn't make sense to me but it's the only thing I can think of.
@mqus commented on GitHub (Jul 22, 2020):
No, the .env file only matters at runtime. In my case, I let other programs take care of reading the .env file and transmit them as env variables to bitwarden_rs, e.g. through systemds
EnvironmentFile. I'll try on my machine (with the 1.16 release) and get back to you.@mqus commented on GitHub (Jul 22, 2020):
I tried to manipulate the .env file by only changing the port and then put the .env file and the binary in the same folder (in my case
/tmp/sometest) and thencded into it and ranThe first output showed the changed port so it seemed to work. (CAVEAT: I am running the sqlite version). I'm assuming that you also compiled with the right feature flags. I'll try the mysql version now, but I'll have to compile it first.
@pdarcos commented on GitHub (Jul 22, 2020):
Thanks @mqus
Yeah I compiled with mysql support and it works when I use DATABASE_URL=mysql://bitwarden_rs:mysecretpassword@localhost:3306/bitwarden_rs directly on the command line.
@mqus commented on GitHub (Jul 22, 2020):
So I also compiled with mysql just now and had the following setup and output (no mysql server is actually running, so starting bitwarden_rs will fail), but it doesn't say anything about the URL not being correct:
I'm not sure why it tries to connect through a socket (and not via tcp to localhost with the default port). But this can be my lack of knowledge.
@pdarcos commented on GitHub (Jul 22, 2020):
Thanks again @mqus
Must be something wrong on my end then.
I'll recompile and start again from scratch.
I'm going to go ahead and close this ticket since it's obviously something I've done wrong and not a bug in bitwarden_rs.
Cheers
@mqus commented on GitHub (Jul 22, 2020):
I think the socket thing is still suspicous and It would be better to close this once you have actually figured out what the issue was. I didn't see anything wrong from your side.
EDIT: Could it be that it tries to read your (old) database configuration from
data/config.json?@pdarcos commented on GitHub (Aug 2, 2020):
Opening this issue again since it seems the strange behavior continues.
I made sure that it isn't reading
data/config.jsonsince I changed its name to config.json.backup and it still seems to ignore my.envfile completely even though it's in the same directory and is properly configured:And then
I don't know why it seems to ignore my .env file when it is there in the same directory:
Any ideas?
@jjlin commented on GitHub (Aug 2, 2020):
Try adding something like
println!("DATABASE_URL = {}", db_url);togithub.com/dani-garcia/bitwarden_rs@f724addf9a/src/config.rs (L427-L429)Rebuild and see what it's getting for that value.
@pdarcos commented on GitHub (Aug 3, 2020):
Thanks @jjlin
I'll try that and report back.
Cheers
@pdarcos commented on GitHub (Aug 3, 2020):
Update. I did a fresh git clone and added the println as @jjlin described above.
I just compiled and now when I start up bitwarden_rs it no longer complains about the missing mysql and connects as expected.
Not sure what the error was but it seems to have gone away after rebuilding.
Thanks to everyone that helped.
Going to go ahead and close.