Karaf command history fail

Karaf is logging correctly, but when entering a command in console, it fails to save the history of commands with:

2022-01-24 11:25:00.506 [WARN ] [org.jline                           ] - Failed to save history
java.nio.file.AccessDeniedException: /var/lib/openhab2/.karaf/karaf.history

For some reason karaf still tries to save history to the wrong directory. The dir permissions for /var/lib/openhab are for openhab, and /var/lib/openhab2 is set as root. I would rather just change the pointer to the correct directory than change permissions to an otherwise empty directory.

Is there a karaf config file that can be modified to correct this location?

Apparently the issue was reported some time back…

https://github.com/openhab/openhab-distro/issues/1195

You may override the default value that you can get from within the karaf console with :

env|grep hist

by adding a line in $OPENHAB_USERDATA/etc/system.properties
like

karaf.history=/somedir/karaf.history
1 Like

Thanks Wolfgang. It worked perfectly.

1 Like

Thanks for the solution :slight_smile:

Migrating from OH2.3 on Raspbian stretch to OH3.4.2-1, using apt install, I’m slowly tracking inconsistencies. And as the OP, I got this issue too and applied the proposed solution in

/var/lib/openhab/etc/system.properties

where I added

karaf.history = ${openhab.userdata}/.karaf/karaf.history

It works, but sadly it’s just a workaround, it doesn’t explain in first place which file the key is (still) initiated from.
In the same way I found that in karaf env (but not in the shell env) “openhab2” still remains :

String          user.country    FR
String          user.dir        /var/lib/openhab
String          user.home       /var/lib/openhab2
String          user.language   fr
String          user.name       openhab
String          user.timezone   Europe/Paris
String          xml.catalog.files

Any clue for where it come from? I couldn’t find it in $OPENHAB_USERDATA files, nor in \etc
I manually removed the remaining openhab2 folders and will check if some error arise in /var/log.