Skip to content

Fix ApiKey detection so it works on Linux - #3

Open
blackadderkate wants to merge 4 commits into
GarethLowe:mainfrom
blackadderkate:main
Open

Fix ApiKey detection so it works on Linux#3
blackadderkate wants to merge 4 commits into
GarethLowe:mainfrom
blackadderkate:main

Conversation

@blackadderkate

Copy link
Copy Markdown

The Steam Compatibility Layer creates a virtual C: drive for each installed game. Which means the Tsw6Api Key is in a different location than on Windows and the API cannot find it.

This patch changes the search logic to detect if we are running on Linux and if so change the search location so it finds the Key.

The Steam Compatibility Layer creates a virtual C: drive for each
installed game. Which means the Tsw6Api Key is in a different location
than on Windows and the API cannot find it.

This patch changes the search logic to detect if we are running on Linux
and if so change the search location so it finds the Key.
@Valkyrien04

Valkyrien04 commented Oct 26, 2025

Copy link
Copy Markdown

This works for the debian install of steam, but most other linux distributions will use flatpak, where the steamapps dir is located at $HOME/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps

Pretty sure this includes the steam deck itself but dragging mine into a position to interrogate its filetree is more effort than I want to go through rn

Flatpak stores the API key in yet another folder.
Add code to search for this too...
@blackadderkate

Copy link
Copy Markdown
Author

This works for the debian install of steam, but most other linux distributions will use flatpak, where the steamapps dir is located at $HOME/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps

Pretty sure this includes the steam deck itself but dragging mine into a position to interrogate its filetree is more effort than I want to go through rn

OK, in theory I've updated the patch to search for Flatpak locations.

I don't seem to have a PC with TSW6 installed running the Flatpak version of Steam on Linux to test it on, but according to the logfiles it's searching here:
$HOME/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/compatdata/3656800/pfx/drive_c/users/steamuser/Documents/My Games/TrainSimWorld6/Saved/Config/CommAPIKey.txt

@Valkyrien04

Copy link
Copy Markdown

trying to test your build myself but unfortunately I'm having issues getting the app to access the API server. I'm sure I'm doing something dumb so we'll see if i can kick it through.

@Valkyrien04

Valkyrien04 commented Oct 27, 2025

Copy link
Copy Markdown

So the actual problem here we both missed is this app cannot handle nonstandard install paths.

I had to learn to use a C# Debugger before it slapped me across the face like a wet tuna, but I learned something so 👍

Good news is I can confirm its working with the flatpak path, just someone will probably want to go back later and allow for TSW being stored in a nonstandard location.

@blackadderkate

Copy link
Copy Markdown
Author

So the actual problem here we both missed is this app cannot handle nonstandard install paths.

I had to learn to use a C# Debugger before it slapped me across the face like a wet tuna, but I learned something so 👍

Good news is I can confirm its working with the flatpak path, just someone will probably want to go back later and allow for TSW being stored in a nonstandard location.

I am 99% sure have a fix for this - I will upload it later.

Get Steam to tell us where the game is installed (and the associated pfx
virtual drive C:) using GameFinder.
@Valkyrien04

Copy link
Copy Markdown

that also seems to affect

So the actual problem here we both missed is this app cannot handle nonstandard install paths.
I had to learn to use a C# Debugger before it slapped me across the face like a wet tuna, but I learned something so 👍
Good news is I can confirm its working with the flatpak path, just someone will probably want to go back later and allow for TSW being stored in a nonstandard location.

I am 99% sure have a fix for this - I will upload it later.

i mean it also seems to affect windows installs, so probably better to handle that in a seperate PR

@blackadderkate

Copy link
Copy Markdown
Author

Not necessary.
On both Linux and Windows, the API key is stored in a subfolder in the user's "profile"on the c: drive.

The reason we have to jump through hoops on Linux is that the c: drive is not real - it is a virtual "container" created by Proton. But the location of that container can vary depending on the user's configuration.
So we have to find out where the c: container is in order to get the location of the user profile and the subfolder containing the key.

Windows doesn't need to do this - the c: drive is real and not a container, so it already knows how to find the user profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants