Datastore / file write issue on Debian

Hi all,

Running 2.7.6 on Linux Debian (Elementary OS), and I found an issue when using the datastore API, and later the file API as backup. This is all happening on simulator.

A simple example that breaks my game:

-- Datastore example:
playdate.datastore.write({ score = score }, "score")
-- Manual file write example:
local file = assert(playdate.file.open("score.json", playdate.file.kFileWrite))
if file then
file:write("{\"score\":" .. tostring(score) .. "}")
file:flush()
end

The errors that show are respectively:

Couldn't open file at score.tmp: No such file

and

No such file.

mkDir and file.open in read mode work without errors.

If you want a reproducible example, I will provide it with my project as soon as this game jam ends :smiley:

This works for me on Fedora. Are your SDK folder Disk/Data folder permissions set up correctly? It needs to be able to open/create a folder and file and rename.

Oh, and make sure you close the file, in your example code you’re not which could cause write errors.

Thank you for the head’s up. I think that might be the case, although on my own I’m not able to figure out where the Data directory is being held on my pc. Could you help indicate it for me? (“Open Data Directory” does not work correctly for me).

If you also know what kind of permissions access I should put on the directory, than please let me know! I assume read/write for the current user.

So, I’ve figured it out, documenting here for others:

Where is the “Data” Directory?

In general, the “Data” folder is inside the PlaydateSDK folder, under .../PlaydateSDK/Disk/Data.

Checking ownership of PlaydateSDK

In my case, the folder was under the owner “staff” (not a user on my pc), I was able to see that through the command ls -l <PlaydateSDK parent folder>, which showed:

$ ls -l ~/Developer
total 12
drwxrwxr-x 5 pc pc 4096 Sep 14 08:21 playdate-luacats
drwxrwxr-x 11 501 staff 4096 Jul 25 20:28 PlaydateSDK
drwxrwxr-x 11 pc pc 4096 Jul 23 05:07 PlaydateSDK-old

As you can see, rather than being under the owner and group “pc”, the updated PlaydateSDK had a different owner that wasn’t being recognized.

Re-assign owner of PlaydateSDK

So, the solution is reassigning the owner, recursively. I did it like this:

sudo chown --recursive <your user> <Playdate SDK path>

in my case, that was the following:

sudo chown --recursive pc ~/Developer/PlaydateSDK

…re-assigning all files and directories in PlaydateSDK to the owner, pc.

And that worked for me!

Glad you got it figured out!