Skip to content

Creating in-memory Realm throws error on iOS 26 due to NSTemporaryDirectory not existing #8789

@liamnichols

Description

@liamnichols

How frequently does the bug occur?

Sometimes

Description

We've seen that around 40,000 of our users are using the iOS 26 betas and out of those users, around 200 have experienced an issue where an in-memory Realm throws an error like the following:

Error Domain=io.realm Code=5 "Failed to open file at path '/private/var/mobile/Containers/Data/Application/7A8ED8E8-569F-4878-98FA-74747F90AFAC/tmp/B4753D61-2989-4886-9E8E-EC87575F3FBA.lock': parent directory does not exist" UserInfo={Error Code=5, NSFilePath=/private/var/mobile/Containers/Data/Application/7A8ED8E8-569F-4878-98FA-74747F90AFAC/tmp/B4753D61-2989-4886-9E8E-EC87575F3FBA.lock, Error Name=FileNotFound, NSLocalizedDescription=Failed to open file at path '/private/var/mobile/Containers/Data/Application/7A8ED8E8-569F-4878-98FA-74747F90AFAC/tmp/B4753D61-2989-4886-9E8E-EC87575F3FBA.lock': parent directory does not exist}

This happens when trying to create an in-memory store with an identifier that is a UUID().uuidString.

Stacktrace & log output

N/A

Can you reproduce the bug?

Sometimes

Reproduction Steps

While I can't actually reproduce the issue on an iOS 26 device myself, I have traced this back to Realm Core trying to create the .lock file inside NSTemporaryDirectory().

The error states that the parent directory does not exist, and I can confirm that the same error is thrown if I deliberately delete the tmp directory from within my simulator data.

My suspicion is that Realm is not actually at fault here, because for a long time we have always expected NSTemporaryDirectory() to exist, but for whatever reason, this doesn't seem to always be the case in the iOS 26 betas.

I'll shortly raise a feedback for this to get further clarification, but I wanted to raise a bug here as well because users of Realm do not have control over using NSTemporaryDirectory() for in-memory stores. While I can add a workaround in my own app to make sure that NSTemporaryDirectory() exists before I use Realm, I can't guarantee that Realm might one-day start using a different directory.

It might be a good idea if Realm adds this kind of guard itself.

Edit: On second thought, I didn't attempt to create NSTemporaryDirectory() on a real iOS device, only a simulator. It might be that this is something that Realm has no control over.

Version

10.54.5

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

iOS 26

Build environment

Xcode version: 16.4
Dependency manager and version: N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions