protonscr

Steam prints "flock (FILE) LOCK_SH failed. errno = 38" errors for each the game that was moved to the external disk

steamopen Flathub-provided steam package
ValveSoftware/steam-for-linux#10829 · opened 2024-04-27 by lufia · updated 2026-06-06 · 13 comments · github
Llufia 2024-04-27 github

Your system information

  • Steam client version (build number or date): 1709846872
  • Distribution (e.g. Ubuntu): Flatpak
  • Opted into Steam client beta?: No
  • Have you checked for system updates?: Yes
  • Steam Logs:
steamwebhelper.sh[127]: Starting steamwebhelper under bootstrap sniper steam runtime at /home/lufia/.var/appcom.valvesoftware.Steam/.local/share/Steam/ubuntu12_64/steam-runtime-sniper
flock /run/user/60331/doc/f9ec6bc3/Steam/libraryfolder.vdf LOCK_SH failed. errno = 38
CAppInfoCacheReadFromDiskThread took 40 milliseconds to initialize
Steam Runtime Launch Service: starting steam-runtime-launcher-service
Steam Runtime Launch Service: steam-runtime-launcher-service is running pid 224
bus_name=com.steampowered.PressureVessel.LaunchAlongsideSteam
flock /run/user/60331/doc/f9ec6bc3/Steam/libraryfolder.vdf LOCK_SH failed. errno = 38
flock /run/user/60331/doc/f9ec6bc3/Steam/steamapps/appmanifest_xxx.acf LOCK_SH failed. errno = 38
flock /run/user/60331/doc/f9ec6bc3/Steam/libraryfolder.vdf LOCK_SH failed. errno = 38
BRefreshApplicationsInLibrary 1: 0ms

(Steam client is launched here, but all game stored on my external disk are not detected.)
  • GPU: AMD

Please describe your issue in as much detail as possible:

My host have an external USB SSD that usually mounted on /run/media/lufia/games.

A few days ago, because my laptop's storage is almost full, I moved large games by Steam > Settings > Storage tool.

After Steam client was restarted I noticed that Steam does not recognize the games I moved to external USB SSD; they are not installed.
Also Steam client can't install new game I bought to the external USB SSD.
Both these two cases above Steam client prints the same errors "flock (FILE) LOCK_SH failed. errno = 38"

(FILE) is such as:

  • /run/user/60331/doc/f9ec6bc3/Steam/libraryfolder.vdf
  • /run/user/60331/doc/f9ec6bc3/Steam/appmanifest_xxxx.acf
  • etc.

Flatpak's permissions

$ flatpak permissions
Table      Object              App                     Permissions                  Data
gnome      shortcuts-inhibitor qemu.desktop            DENIED                       []
background background          com.valvesoftware.Steam yes                          0x00
documents  f9ec6bc3            com.valvesoftware.Steam read,write,grant-permissions (b'/run/media/lufia/games/Steam', 76, 257, 4)

I have tried

I have tried to get shared lock on the host directly, it worked:

$ cd /run/media/lufia/games/Steam
$ flock -s libraryfolder.vdf ls
libraryfolder.vdf  steamapps

I also tried to get shared lock within flatpak, it failed:

$ flatpak run --command=bash com.valvesoftware.Steam
$ cd /run/user/60331/doc/f9ec6bc3/Steam
$ flock -s libraryfolder.vdf ls
flock: libraryfolder.vdf: Function not implemented

Steps for reproducing this issue:

  1. Install com.valvesoftware.Steam
  2. Attach an external storage to the Linux box
  3. Move one or more games with Steam client
  4. Restart Steam client
Kkisak-valve maintainer 2024-04-27 github

Hello @lufia, your symptoms resemble the discussion on #9776. Please give that issue report a read and see if it's relevant to you.

Llufia 2024-04-27 github

Hi @kisak-valve

I had read that issue you mentioned, I think that issue is very similar to this.
However, I couldn't understand what I should do to fix this because that's author commented:

I'm not sure what did it to be exact...

I checked mounts

$ grep /run/user /proc/$(pidof -s steam)/mounts
tmpfs /run/user/60331 tmpfs rw,nosuid,nodev,relatime,size=3255252k,nr_inodes=813813,mode=700,uid=60331,gid=60331,inode64 0 0

$ grep /doc /proc/$(pidof -s steam)/mounts
portal /run/flatpak/doc fuse.portal rw,nosuid,nodev,relatime,user_id=60331,group_id=60331 0 0
Llufia 2024-04-28 github

Today I noticed that /run/user/60331/doc is symbolic link refers to /run/flatpak/doc.

Therefore, I now suspect XDG Desktop Portal wouldn't implement flock operation yet if the error message is correct.

Current versions in my Arch Linux box:

  • flatpak 1:1.15.8-1
  • xdg-desktop-portal 1.18.4-1
  • xdg-desktop-portal-gnome 46.1-1
Llufia 2024-04-29 github

@kisak-valve

I'm not sure whether it will be merged or not, I created a PR to xdg-desktop-portal repository to merge a patch that is to fix this issue.
https://github.com/flatpak/xdg-desktop-portal/pull/1353

But, the patch would add only non-blocking operations of flock(2) because blocking ops could block entire xdg-document-portal filesystem.

I have a question: Steam client might involve flock(2) with blocking operation?

For now, Steam works well with an external drive.

Wwiiznokes 2024-07-04 github

I also have this issue on Fedora 40, Gnome 46, steam version: 1718904662

Stream is installed via flatpak. I want to install a game on a separate SSD. I try to give the permission using flatsteal, using the filesystem section, as mentioned in the issue. Steam is able to write some folder and file in this directory, but as soon as i start to install the game, it give me the error.

Bbdols 2024-07-20 github

It wasn't clear what the workaround was in https://github.com/ValveSoftware/steam-for-linux/issues/9776
but I was able to workaround it with flatpak override --user com.valvesoftware.Steam --filesystem=/var/mnt/games and I'm able to install games to a second drive mount. I needed to exit out of steam and start it again after setting that override. I'm also running a FC40 based OS.

Wwiiznokes 2024-07-20 github

I personally could install my game with KDE, so I think it's a gnome specific issue

DDutt-A 2024-07-23 github

I am having this exact same issue on Fedora 40 Sway edition. I hope your fix can eventually make its way downstream so I can download it on Fedora.

Mmarscher 2024-11-13 github

When I unmounted /run/user/$something/doc, the updates where successful. At least I consider this now a workaround. It would be nice if the flock patch would be accepted.

EDIT: it only works, if I first replace the xdg-portal-document process with the one of the proposed PR, then forcefully unmount the FS as root. It is very strange...

Ttoomanydev 2025-05-09 github

I personally had an issue where I had this error (found it with strace) when I tried making a second library in Steam.
flock /run/user/1000/doc/bca8fd30/Steam/steamapps/downloading/state_736260_736263.patch LOCK_SH failed. errno = 38
It would make the second library, drop files in there, but got a disk write error when it came to download and write the game files.
I gave it sufficient permissions in Flatseal, and this was evident because it was creating files in the target library folder.
The issue was that without the permissions, it wanted to use the portal, but the portal doesn't like flock. And even though I gave it permissions after, Steam was still trying to write to the portal while using the unsupported flock.
This was resolved by deleting the library in Steam and recreating it.
I suppose the reason why Steam was able to make the other files was because it didn't use flock while writing them.

tl;dr
Make sure Steam's writing files at all to the folder, if it isn't making any files then give it permissions in Flatseal, if it is creating files but also then giving you a disk write error, then re-creating the library in Steam may fix it.

Thanks, guys :)

DDanny3 2025-05-15 github

tl;dr Make sure Steam's writing files at all to the folder, if it isn't making any files then give it permissions in Flatseal, if it is creating files but also then giving you a disk write error, then re-creating the library in Steam may fix it.

Thanks, guys :)

I gave the permissions to the drive like this:
flatpak override --user --filesystem='/media/my-username/SSD-drive' com.valvesoftware.Steam
As I always found Flatseal and KDE's control panel page confusing for this task.
For some reason it didn't work until I saw your comment and decided to delete the folder, in which I want the library to be and recreate it again and then re-create the library to it in Steam.
Now it works, thanks to your very useful comment!

Ggechoto 2026-03-29 github

Just so you know the Steam flatpak added a workaround for this by allowing full permission on all external and secondary disks.

This makes it work for now without doing the flatpak override.

However be aware that this massively breaks security as Steam (and any game and malware installed by it) can now do anything on your disks.
Since it is fairly common to have backups of you private files on secondary disks this can be somewhat similar to malware now having full access to your home directory and being able to steal SSH keys for example as well as infect other files in you backups which makes it easy for the malware to spread.

I hope this can be fixed soon but we have to wait for this:
https://github.com/flatpak/xdg-desktop-portal/issues/1951

DDanny3 2026-06-06 github

Very good points!
I think the best security would be to give per folder permissions and even there to be able to restrict it even more by setting it read-only when we are sure there is not need to modify or create new things.
But since it's hard to guarantee that these things are possible and when they are, that indeed nothing can escape the constraints, I started moving personal file outside of the home directory.
I don't have any SSH keys, but if I'll ever do, I am wondering what can be done to protect those and make the config still work.
Maybe move the config to partition that must be mounted and then put a symlink in it's original location so that everytime the symlink must work, the partion must be mounted and a passwork is required.