Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to open file at path '/default.realm.lock': Operation not permitted #237

Open
adamski opened this issue Jul 31, 2024 · 10 comments
Open

Comments

@adamski
Copy link

adamski commented Jul 31, 2024

What happened?

I expected to be able to have realm load inside an app or AUv3 plugin running on iOS.

I got an exception with the message: "Failed to open file at path '/default.realm.lock': Operation not permitted"

I would expect the lock file to be saved in the same location as the database path.

Repro steps

Build an application with Realm 2.2.0, that tries to open a local realm. Build for iOS and run on an iOS device.

Version

2.2.0

Installation method

CMake / CPM

What Atlas Services are you using?

Atlas Device Sync

Compiler

Apple Clang (Xcode)

OS and version

iOS 16

Code snippets

No response

Stacktrace of the exception/crash you're getting

No response

Relevant log output

No response

Copy link

sync-by-unito bot commented Jul 31, 2024

➤ PM Bot commented:

Jira ticket: RCPP-88

@adamski
Copy link
Author

adamski commented Aug 1, 2024

@leemaguire do you have any insight into this issue? It seems to be new, as my iOS builds were working on a previous version of realm-cpp.

@leemaguire
Copy link
Contributor

@adamski where is the path being set? Did you ensure you're using the documents folder in your apps sandbox?

@adamski
Copy link
Author

adamski commented Aug 2, 2024

@leemaguire this is path to the database I'm passing in the app config, in this example showing the absolute path in the Simulator

/Users/adamwilson/Library/Developer/CoreSimulator/Devices/2DFBB86A-A61E-4727-8947-3F5B01AD35AE/data/Containers/Data/Application/4FCA6EE6-7736-45A8-A895-965E7FA3E2FF/Library/Node Audio/Entonal Studio

@leemaguire
Copy link
Contributor

If you don't pass the custom path does the issue persist? Have you tried looking at file protections in iOS? https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/realm-files/configure-and-open-a-realm/#use-realm-when-the-device-is-locked

@adamski
Copy link
Author

adamski commented Aug 2, 2024

The issue only occurs when opening a local realm. If I only open the realm once logged in, it works.
I think I see the issue now - I was assuming I was getting the path from the realm::App instance but that is not passed in when creating a local realm.

I tried this but got an error saying the path is a directory:

         realm::db_config localConfig;
         localConfig.set_path(filePath);
         localRealm = std::make_unique<realm::db> (std::move (localConfig));

@leemaguire
Copy link
Contributor

leemaguire commented Aug 2, 2024

@adamski append "/my_custom_name.realm" to the filePath.

@adamski
Copy link
Author

adamski commented Aug 2, 2024

Thanks @leemaguire - should the name be different to the synced realm or can they be the same file?

@adamski
Copy link
Author

adamski commented Aug 2, 2024

I guess they have to be different.. in which case I'd need to merge local and synced when logged in?

@leemaguire
Copy link
Contributor

They can be the same, I think this will be useful to you #234.

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

No branches or pull requests

2 participants