X11/xkb conflict while upgrading system

So, when I ran sudo pacman -Syu (or yay -Syu) I got an error right at the end which said there was a conflict and the upgrade was abandoned.
It said: xkeyboard-config: /usr/share/X11/xkb exists in filesystem.
I had a hunch as to why this was happening. I had added a custom keyboard mapping file inside /usr/share/X11/xkb/symbols.
I tried again after moving that file out and it worked without issues. And then I moved the file back.

2 questions:

  1. Why did this happen? Is it because the directory contents didn’t match with the new one?
  2. What would be a long term workaround for this?

P.S: First time posting on the forum : )

1 Like

Welcome to the forum :enos_flag: :enos:

Try something like this :

1 Like

Welcome here, @namskash!

Looks like you did exactly the same I did: I modified my German E2 keyboard settings /usr/share/X11/xkb/symbols/de to use the <> key as a level 5 instead level 3 shift, and a few days ago Pacman complained with exact your error message.

I was pretty impressed that it seems to “know” that changes were made (maybe it keeps checksums somewehere? Or was it just the backup file I made?).

Long story short: I copied my changed /usr/share/X11/xkb/symbols/de, put the backup /usr/share/X11/xkb/symbols/de.bak in its place again, and re-updated—success!

Of course I then replaced the file again against my changed one, rebooted, and all is back as intended,

I also wonder

  • why this happened (seems a good safety feature), and
  • how to do such a change correctly (and permanently)

Maybe someone more knowledgeable here can shed some light on this, for both of us.

1 Like

So ..

/usr/share/ is generally somewhere we leave to packages/distro.

User-configurations should go in $HOME or /etc/ or else somewhere defined by the given software.

In the case of xkb then that would be

~/.config/xkb

You manually placed a file at a path that is tracked/provided by a package.

Not doing what you did. See above. :wink:


Reference:
https://xkbcommon.org/doc/current/user-configuration.html#md_doc_2user-configuration

4 Likes

:rofl:

Ah, great! Wasn’t aware that ~/.config/xkb would work for X11 stuff, too! (Maybe it is actually ~/.config/X11/xkb?) Thanks a lot! We’d just put the changed files there, right?

And for all users, like in /etc/X11/xkb/…?

1 Like
3 Likes

As always, thanks for the pointers—much obliged!

2 Likes

Just to be clear those were not instructs for X11 in general .. but specific to xkb.

I dont think you can put X11 configs in home for the most part .. besides a few specific ones like .xserverrc.

And they were generalized, as you may have noticed with “most distributions..” and similar in the wording.

The Arch wiki has a page itself:

The xorg bugs note is a bit funny .. but it seems that actually the old friend /etc/X11/xorg.conf.d is the suggested path for global custom rules.

1 Like

Thank you all for your answers!
So, from what I understand, I should move the custom file to ~/.config/xkb
Follow-ups:

  1. Where exactly can I set the $XKB_CONFIG_ROOT env var so that xkb identifies the ~/.config/xkb dir?
  2. Also, if I want KDE to see this too so that it shows up in System Settings > Keyboards, what can I do?

Putting my changed xkb/symbols/de file into ~/.config/xkb/symbols/de didn’t work out on EOS/Cinnamon, I suspect because of

Note
Where libxkbcommon runs in a privileged context, only the system (<datadir>) path is available.

See: https://xkbcommon.org/doc/current/user-configuration.html#user-config-locations

In a terminal, $XKB_CONFIG_ROOT and $XKB_CONFIG_EXTRA_PATH are shown empty (undefined).

When I have some time, I’ll do further testing.

You do not need to.
If undefined it uses the listed paths.

But if you really wanted to set a variable you could again use either ~/.config/environment.d/* or /etc/environment - depending on if it is acceptable as an env var loaded by user or globally.

KEY=VALUE is the accepted syntax in the file.

Considering the reply below yours and what you may be trying to do then maybe /etc/ in the way to go.

Furthermore I might mention you probably do not want to set XKB_CONFIG_ROOT .. if a custom path is desired for any it would likely be best to use XDG_CONFIG_EXTRA_PATH, ie something like: XDG_CONFIG_EXTRA_PATH=/etc/mycustompath or similar.

1 Like