Linux: debugging for missing files in Steam Workshop Mods

I wanted to use some mods with Civilisation 6 but once installed, parts of the game did not work properly anymore.

One of the crucial differences between Windows and Linux, is that Linux cares for uppercase and lowercase letters in filenames. So a Mod Developer using Windows may not even recognize that a filename has a case issue.

To debug the files a program wants to access you can use strace on Linux.

Using strace on steam workshop mods

# sudo strace -f -p 192370 2>&1 | grep 289070 | grep 'File '

The above will attach to the "Civ6Sub" process ID 192370 (always different) and listen to all events. Additionally this hides all errors outputs, isolates every line that contains the Civilisation Mod-Folder "289070" and additionally filter for the "File not found" text message in this stream.

Doing this showed me 3 file errors during Game start that showed up in the trace as lowecase filename (which were not found). The actual files had indeed mixed-case filenames. However I couldn't find them used in lowercase form in the code.
It seems the game performs a lowercase conversion forcing all filenames to be lowercase. Not an issue in Windows … but on Linux this is a serious and not very obvious issue (if not to say "trap").

How to get the process ID of a program?

You should know the program's name (e.g. Civ6Sub). You may be able to observe it in your System Monitor application.

# ps aux | grep "Civ6Sub"

ruediger  192370  0.0  0.0  31568  7260 ?        S    16:52   0:00 /bin/sh /mnt/games/Steam/steamapps/common/Sid Meier's Civilization VI/./Civ6

In the above output 192370 is the process id.

How do I know the mod-folder of a Steam game

When you open the game's page on the Steam website, the URL reveils the Game ID: https://store.steampowered.com/app/289070/Sid_Meiers_Civilization_VI/

The above URL contains the game ID: 289070

Mods are located where Steam is installed, in the workshop folder.

So the folder where the mods are located is
/path/to/Steam/steamapps/workshop/content/289070/
(often it is ~/.local/share/Steam)

How I solved my problem then

On my particular issue with "Sukritact's Simple UI Adjustments" I was able to find help in the mods Forum, where this issue was reported (and the below patch mentioned):
https://steamcommunity.com/workshop/filedetails/discussion/939149009/4241773359648346080/

cd ~/.local/share/Steam/steamapps/workshop/content/289070/939149009/
find -name '*.lua' -o -name '*.xml' | sed -n 's/\(.*\/\)\(.*\)/ln -s \2 \1\L\2/p' | sh

This is very elegant as it produces a terminal command using sed for search & replace and finally executes that command. The resulting commands creates a symlink with a lowercase version of the original file but does not touch the path to the file.

.*\/ matches everything until the last /. So the second part
.* matches only the filename

The matched filename is then converted to lowecase using \L\2

Consequently for every file it finds, the command will look something like

ln -s UI/Common/CityPanel.xml UI/Common/citypanel.xml