Keepassxc: Does not open last used database automatically

Created on 28 Jun 2020  路  25Comments  路  Source: keepassxreboot/keepassxc

Hi!
I often have the issue, that when using the global autotype shortcut, nothing happens, because KeepassXC does not open the last used database. I have to open the main window and select the last (and only) database from the recents list. Then it works for a while. Maybe there should be an option to set the default database.

duplicate

Most helpful comment

Okay. I do understand that saving a "recently used" list in ~/.config is "wrong". I don't understand why ~/.cache instead of ~/.local/share was chosen though as the latter would make much more sense (to me at least - it's definitely not "non-essential data" in my eyes).
So replacing QStandardPaths::GenericCacheLocation with QStandardPaths::AppDataLocation at https://github.com/keepassxreboot/keepassxc/blob/5c2a1a4284c1bccfcd99a861336559105ed3db7d/src/core/Config.cpp#L449
should make everyone happy?

All 25 comments

I'm confused by the problem. Do you even have the database open in keepassxc? We don't open a database file when you auto-type, you need to do that first. It doesn't have to be unlocked, but it does have to be "open".

Sorry, I did not mean opened and unlocked, but selected with its keyfile, so that you only have to type the passphrase.

Do you have "remember last databases and key files" setting set?

image

Yes, I have. But it seems, that it sometimes does not know, what the last db was. I have this issue on multiple machines.

I am going to need screenshots or a demo video to understand what your problem is, sorry.

Ok, I attached a screencast. I am trying to log into Github via autotype, but nothing happens, because the last used database was not remembered after a reboot. I have to open the KeepassXC window and select my database from the list of the last opened (I have only one database).This does not happen every time, but very often. The expected behabiour is, that my last used database it opened every time, and I am only prompted to unlock it.
keepassxc.tar.gz

When you close keepassxc do not close the database (don't press Ctrl+W). That will require you to open it again on launching keepassxc.

I do not close the db. The issue is mostly after reboots or resumes.

Is your db hosted on a network shares that might not be connected or available?

No, the db file is always present in the locsl filesystem.
I suggest, when using the autotype shortcut, and only one recent db file is in the list, always to use this one. Or opening the application to let me choose the db, instead of doing nothing.
My wife also has this issue. Maybe it is related to resuming from hibernation. I did not have this somewhere in the past. But I cannot say, when it appeared for the first time, or with the move from KeepassX to KeepassXC.
But when you or anybody else never had this issue, it seems to be my fault.

I was facing the same problem.

In the settings GUI the option "Load previously used database" was set but in the ~/Library/Application Support/keepassxc/keepassxc.ini file the option OpenPreviousDatabasesOnStartup was set to false.

I changed the value to true and chose a file from "Recent databases". It works fine ever since...

UPDATE: That only worked until I cleaned up ~/.cache!

I have the same problem. After a reboot keepass forgets what my last database was. As long as I don't reboot it works fine. I have the GUI Settings enabled and OpenPreviousDatabasesOnStartup is also set to true.

EDIT:

OK I found the problem.

The last database is now saved in ~/.cache/keepassxc/keepassxc.ini. This was saved somewhere else before? I use a tmpfs for ~/.cache/, which explains what is happening.

This is a common theme and unfortunate finding

I have the same issue.

Despite "_Remember previously used databases_", "_Load previously open databases on startup_" and "_Remember database key files and security dongles_" being checked in "Application Settings > Basic Settings", whenever I quit the application to reboot the system, I have to provide explicitly the name of both DB and key when I open KeePassXC. Also, the settings are correctly saved in the keepassxc.ini file

I've never had the problem before v2.6.0, and I've been using KeePassXC for years.

It does not happen when I just quit the application (Cmd+Q).

Both files (DB & key) are located on a USB drive, but they are both available when I start KeePassXC.

OS: macOS Mojave 10.14.6
Screen Shot 2020-07-17 at 1 48 15 PM
Screen Shot 2020-07-17 at 2 53 45 PM

Sounds like a completely different issue. Please open a new ticket for that

Same for me, ~/.cache is on tmpfs and therefore wiped after a reboot. This is new behavior since v2.8.0, it was always working fine before that.

Technically we are not doing anything wrong, mounting .cache to a tempfs is not a best practice that we are aware of. Cache is meant to survive reboots, but not be synced with other machines. We are using standard Qt directories for "local config" storage, so your actions to mount to a tempfs may impact other applications function.

Technically we are not doing anything wrong, mounting .cache to a tempfs is not a best practice that we are aware of. Cache is meant to survive reboots, but not be synced with other machines. We are using standard Qt directories for "local config" storage, so your actions to mount to a tempfs may impact other applications function.

Yes you are right. This is not a problem of keepassxc. I have other applications that save configs in .cache. I save them somewhere else and just symlink them to .cache after each start.

For example I use this for keepassxc:

mkdir -p ~/.cache/keepassxc && ln -s ~/keepassxc.ini ~/.cache/keepassxc/keepassxc.ini

There is a single base directory relative to which user-specific non-essential (cached) data should be written. This directory is defined by the environment variable $XDG_CACHE_HOME.

$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored.

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Imo the "last opened" list is not non-essential data and should go into XDG_DATA_HOME instead.

Also I've had this set up for multiple years already and have never seen any issues with other applications.

edit: after some searching around I believe pre-2.8.0 the file location was ~/.config/keepassxc/keepassxc.ini and now it's ~/.cache/keepassxc/keepassxc.ini

The source change seems to be https://github.com/keepassxreboot/keepassxc/commit/596d2cf425c3c8495b4c4a58c61798afe9fdd536#diff-461928dbf0b7b4c50bab629bfe990c75L141-L170

Yes the change is deliberate and the directory choice is correct

@droidmonkey I don't really understand why the change was done though. Were there problems with ~/.config/keepassxc ?

We store settings in both places. Ephemeral, system specific settings are stored in the "local" storage, which on Linux corresponds to the .cache directory. All other settings remain in .config. This allows users to sync their settings across devices, or add to their dot-file git repo without exposing somewhat personal data or information that changes often.

Okay. I do understand that saving a "recently used" list in ~/.config is "wrong". I don't understand why ~/.cache instead of ~/.local/share was chosen though as the latter would make much more sense (to me at least - it's definitely not "non-essential data" in my eyes).
So replacing QStandardPaths::GenericCacheLocation with QStandardPaths::AppDataLocation at https://github.com/keepassxreboot/keepassxc/blob/5c2a1a4284c1bccfcd99a861336559105ed3db7d/src/core/Config.cpp#L449
should make everyone happy?

Ping @phoerious

5313 better captures the issue, workaround, and discussion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheZ3ro picture TheZ3ro  路  3Comments

rugk picture rugk  路  3Comments

shyim picture shyim  路  3Comments

nfnty picture nfnty  路  3Comments

haroldm picture haroldm  路  3Comments