I'm preparing to take a demo of my game on Steam Deck to have some friendly gamedevs try it out and give feedback. The game runs perfectly on my local Windows PC, both from the editor and from a Windows export file. My Linux Export on the Steam Deck runs fine for the most part, but there's some functionality that doesn't, and it appears to have to do with copying some files from the local "res" to the "user" directory.

I have the following code:

var err = dir.copy("res://data/FileImUsing.json","user://data/FileImUsing.json")
		print("Err data = " +str(err))

And this returns an "Err Data = 7", so "file not found" error.

Since in this early stage I just run the game from the Steam Desktop (mode), it's not from the Steam store client or anything. I figured out how to do (not well-versed in Linux) this from the Konsole and that's how I figured out the copying wasn't working.

Extra information: pck is embedded in export.

And full code block (after check if user file already exists or needs to be copied first) is:

var dir = Directory.new()
		dir.open("user://")
		dir.make_dir("data")
		var err = dir.copy("res://data/FileImUsing.json","user://data/FileImUsing.json")
		print("Err data = " +str(err))

Just pretend the res folder doesn't exist. It's there for access in the editor so you can import assets, that's about it. It is not accessible on export for security reasons. It may or may not work on some operating systems, but this is not intended functionality.

But that's what I'm using it for. At bootup, put json files into user so I can use them later on. I never touch res afterwards. Is there a different way to put my json files into user?

The way it's set up I found as a solution when releasing my first bigger Godot game and found out that res was not accessible in exported version; on Windows copying to res worked and was recommended as a solution because it was said not to be platform dependent. I thought perhaps the problem was with the permissions of the file or something.


(to be clear, I have .json files included in export)

Do dir.open() or dir.make_dir() return non-zero error codes?

What's the return value of dir.file_exists("res://data/FileImUsing.json")?

You might have to make the .json files Resources, and load() or preload() them, rather than accessing them as normal files.

I don't think you're allowed to have file access to res. I'm not sure why it works at all. But load/preload might work.

On SteamDeck, I get an 0 return code for the dir.open, but apparently a 32 (already exists) for the dir.make_dir. Right, gonna have to look for where the user directory is made and remove it for a clean bootup. It seems not to be just in "Home" on Deck.

On windows (exported version, freshly emptied user (app_userdata)) all of this just works:

Dir open feedback: 0
Dir make dir feedback: 0
Err data = 0
Err data = 0
Err data = 0

Have located user, cleaned up game folder and now also get 0 feedback for making the directory. But I do indeed get a false for file_exists.

Converting to Resources at first view would have a big impact on all of my implementation. I think for my save file, I'd still want to export and read from a JSON file in user? It seems Godot 4 is also planning to make json files actual resources so this would fix the problem? Sighs in 3.5.1 ^^'

... whoops.

Turns out this

filter is not shared between different export types (Windows/Linux), and it was still empty for the Linux build.

My apologies. ^^'

I'm still getting a script error that says "cards.json" does not exist, but did get "0" error returns. And I can see that the "cards.json" file was made in the user directory. Might be a capitalization issue.

I read somewhere that in an export, the res:// directory is merged into the executable code, unlike the user:// directory, which is mapped to a directory on the target platform's file system. If that's the case, then file system operations wouldn't work on res:// in an export, unless file system references to res:// are somehow handled as a special case.

There's some information about this in the manual, but that aspect of it is not clear.
https://docs.godotengine.org/en/stable/tutorials/io/data_paths.html#file-paths-in-godot-projects

The core developers who fully understand these details rarely post here. You could try asking about this in the Godot Contributors Chat:
https://chat.godotengine.org/

They sometimes answer questions in the Godot Reddit:
https://www.reddit.com/r/godot/

Should have updated. After fixing

  • the .json export so that it also does this for Linux
  • the capitalization errors that I had. I just had two typos where I had given a capital D to the "/data" in my URL, and found out this is not a problem for Windows as it's apparently not case-sensitive even though you can use capitals in folder names, but is a problem for Linux that then goes looking for the wrong file.

it now works on Linux as well! Seeing that it really said "file not found" made me think again whether the json files were actually included and made me click around more in that export window, finding out those settings are applied per export template. So the fix was also in the lines of what I originally expected, as I was always told Godot can still read from res, it just can't write to it.

I've been since working on a presumably wholly unrelated performance issue. Steam Deck is not handling the lights as well as my desktop is (which makes sense, my desktop has a beefy GPU)