HOWTO Update XDG-USER-DIRS To Avoid Symlink Issues With Flatpak

(If the title did not make sense to you, give this one a skip. It’ll only be important to a few people, but to those people it will be VERY important.)

TL;DR: If a flatpak program is giving you an error like this:

bwrap: Can't make symlink at /home/steven/Music: File exists

then you need to have your XDG user directories updated to point at the actual location, not a symbolic link. Directions below.


For various reasons, I ended up having to reinstall the operating system on a PC. (I took some time off, of course a bunch of computer stuff broke.)

There’s a particular bug affecting Steam with some video cards on linux (documented here) that I ran into. Since the nouveau drivers had been causing me some serious problems, and I didn’t want to re-reinstall graphics card drivers, I decided to try the flatpak installation of Steam instead so it came with all its own dependencies.

At which point I ran into another documented bug where Flatpak throws a fit if one of your "XDG user directories" is a symlink to somewhere else. Steam wants read access to your Pictures and Music directory, and so if they are a symbolic link, it complains with a message of bwrap: Can't make symlink at /home/user/Music: File exists.

While dismissed as an "edge case" or "the wrong solution" the latter comment actually pointed me to what the real fix.

Your XDG user directories should point to the actual directory.

There’s two easy ways to accomplish this:

You can use the xdg-user-dirs-update tool (note that MUSIC and PICTURES are upper case):

xdg-user-dirs-update --set MUSIC /some/custom/path
xdg-user-dirs-update --set PICTURES /some/custom/path

or you can edit $HOME/.config/user-dirs.dirs and change the appropriate lines:

XDG_MUSIC_DIR="/some/custom/path"
XDG_PICTURES_DIR="/some/custom/path"

After that, the flatpak will run just fine.

{1} Why would you do this? Because your boot or root drive is small and you have a huge music, video, or photo directory. In my case, my music directory is several hundred gigs by itself.

Featured image Image by neo tam from Pixabay