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

'default.realm.lock': open() failed: Operation not permitted #7943

Closed
MarouMhz opened this issue Sep 5, 2022 · 10 comments
Closed

'default.realm.lock': open() failed: Operation not permitted #7943

MarouMhz opened this issue Sep 5, 2022 · 10 comments
Labels

Comments

@MarouMhz
Copy link

MarouMhz commented Sep 5, 2022

How frequently does the bug occur?

Sometimes

Description

We have tracked in our Crashlytics that some users (approximately 300 users) failed to create Realm file with this error 'default.realm.lock': open() failed: Operation not permitted

We have tried to fix this according to this solution, we have set protection at none to the folder that contain default.realm and default.realm.lock before opening realm

Stacktrace & log output

Unable to open a realm at path '<path_to_Documents>/default.realm.lock': open() failed: Operation not permitted Path: <path_to_Documents>/default.realm.lock Exception backtrace: 0 Realm 0x000000010760b3e4 _ZN5realm4util4File13open_internalERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS1_10AccessModeENS1_10CreateModeEiPb + 712 1 Realm 0x00000001074bf620 _ZN5realm2DB4openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS_9DBOptionsE + 988 2 Realm 0x00000001074c2968 _ZN5realm2DB4openERNS_11ReplicationERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS_9DBOptionsE + 124 3 Realm 0x00000001074c7134 _ZN5realm2DB6createE

Can you reproduce the bug?

Not yet

Reproduction Steps

This crash is found on the Firebase console, we can't reproduce it. According to the Firebase, it happens more than 300 times and affects more than 200 users. we tried many solutions like this but we still have this issue:
#7874 (comment)

Version

Realm 10.28.2 and earlier

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

iOS15

Build environment

Xcode version: XCode 13.4
Dependency manager and version: cocoapods 1.11.3

@ericjordanmossman
Copy link
Contributor

Could you share the block you use to set the file protections? I know you linked @dianaafanador3 's Obj-c example from 7874, but in case your using swift or changed it up.

I'm wondering if you're hitting something like this. Create a custom sub-directory, if you're not already, and set those protections. Setting the protections for the app's default Documents might not stick.

@MarouMhz
Copy link
Author

MarouMhz commented Sep 7, 2022

Thanks for your reply. It's this we tried to set those protections to default Documents.
So we will create a custom sub-directory and check if this solve this issue in release version.

If we will do this we should move all realm files to this sub-directory, you know if there is other file/directory related to realm to move ?
default.realm.lock
default.realm
default.realm.management

@ericjordanmossman
Copy link
Contributor

Yes should be those three. Keep in mind that some of these files might get created and deleted by realm system processes, so you can't just apply the protections to the file. Do it to the whole sub-directory. Like mentioned in the earlier link, I think the sub-directory has to be created by you, and not the Documents/.

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Sep 7, 2022
@MarouMhz
Copy link
Author

MarouMhz commented Sep 7, 2022

yes thank you
we will make feedback here after release of this fix

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Sep 7, 2022
@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels Sep 7, 2022
@leemaguire
Copy link
Contributor

@MarouMhz just checking in to see if you have any feedback after implementing the above suggestions?

@MarouMhz
Copy link
Author

MarouMhz commented Feb 6, 2023

We always have crashes reported on Crashlytics even by moving the realm files to Library/Application Support/Realm/

...../Library/Application Support/Realm/default.realm.lock': open() failed: Operation not permitted

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Feb 6, 2023
@jsflax
Copy link
Contributor

jsflax commented Feb 7, 2023

@MarouMhz this is not a valid iOS directory. Can you show us where you are setting the Realm path and tell us why you need to be setting it to a custom path?

@leemaguire
Copy link
Contributor

@MarouMhz do you have any follow up on our last question?

@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels Feb 14, 2023
@leemaguire
Copy link
Contributor

Closing due to no response from user.

@sync-by-unito sync-by-unito bot closed this as completed Mar 29, 2023
@jmtiimo
Copy link

jmtiimo commented Feb 12, 2024

@MarouMhz did you ever find a solution for this?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants