{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/5456","repository_url":"https://api.github.com/repos/realm/realm-cocoa","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/5456/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/5456/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/5456/events","html_url":"https://github.com/realm/realm-cocoa/issues/5456","id":271586164,"number":5456,"title":"Error Domain=io.realm Code=2 \"Unable to open a realm': Incompatible histories. Expected a Realm with no or in-realm history.","user":{"login":"bruce-lumo","id":20171209,"avatar_url":"https://avatars2.githubusercontent.com/u/20171209?v=4","gravatar_id":"","url":"https://api.github.com/users/bruce-lumo","html_url":"https://github.com/bruce-lumo","followers_url":"https://api.github.com/users/bruce-lumo/followers","following_url":"https://api.github.com/users/bruce-lumo/following{/other_user}","gists_url":"https://api.github.com/users/bruce-lumo/gists{/gist_id}","starred_url":"https://api.github.com/users/bruce-lumo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruce-lumo/subscriptions","organizations_url":"https://api.github.com/users/bruce-lumo/orgs","repos_url":"https://api.github.com/users/bruce-lumo/repos","events_url":"https://api.github.com/users/bruce-lumo/events{/privacy}","received_events_url":"https://api.github.com/users/bruce-lumo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-06T19:09:08Z","updated_at":"2017-11-07T19:30:38Z","closed_at":null,"author_association":"NONE","body":"## Goals\r\nUnderstand and avoid Realm Error code 2 \"Incompatible histories\"\r\n\r\nIts not obvious to me which error on this page is the one I'm seeing: https://realm.io/docs/swift/3.0.1/api/Classes/Realm/Error.html#/s:ZvVC10RealmSwift5Realm5Error10fileAccessOVSC8RLMError4Code\r\n\r\n\r\n## Expected Results\r\nNot get this error\r\n\r\n## Actual Results\r\nUser experienced service interruption because their realm file could not be opened. \r\n\r\n## Steps to Reproduce\r\nUnsure. Its not crashing so I don't have a stacktrace.\r\n\r\n## Code Sample\r\n```do{\r\n                        realmToReturn = try Realm()\r\n                    } catch let swiftError {\r\n```\r\n\r\n## Version of Realm and Tooling\r\n\r\nRealm framework version: 3.0.1\r\n\r\nXcode version: 9.1\r\n\r\niOS/OSX version: iPhone SE, iOS 11.0.3\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/comments/342595328","html_url":"https://github.com/realm/realm-cocoa/issues/5456#issuecomment-342595328","issue_url":"https://api.github.com/repos/realm/realm-cocoa/issues/5456","id":342595328,"user":{"login":"bruce-lumo","id":20171209,"avatar_url":"https://avatars2.githubusercontent.com/u/20171209?v=4","gravatar_id":"","url":"https://api.github.com/users/bruce-lumo","html_url":"https://github.com/bruce-lumo","followers_url":"https://api.github.com/users/bruce-lumo/followers","following_url":"https://api.github.com/users/bruce-lumo/following{/other_user}","gists_url":"https://api.github.com/users/bruce-lumo/gists{/gist_id}","starred_url":"https://api.github.com/users/bruce-lumo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruce-lumo/subscriptions","organizations_url":"https://api.github.com/users/bruce-lumo/orgs","repos_url":"https://api.github.com/users/bruce-lumo/repos","events_url":"https://api.github.com/users/bruce-lumo/events{/privacy}","received_events_url":"https://api.github.com/users/bruce-lumo/received_events","type":"User","site_admin":false},"created_at":"2017-11-07T19:30:38Z","updated_at":"2017-11-07T19:30:38Z","author_association":"NONE","body":"Local realms only.\r\n\r\nYes, I am changing the config, see below:\r\n```\r\n // Create desired path for Application Support in user Library, assure it exists\r\n        let libraryPath = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true)[0]\r\n        let userPath = URL(fileURLWithPath: \"Application Support/\\(profile.email).realm\", relativeTo: URL(fileURLWithPath: libraryPath))\r\n        self.assureApplicationSupportExists()\r\n\r\n        // Apply path and schema to realm config\r\n        var config = Realm.Configuration(shouldCompactOnLaunch: { totalBytes, usedBytes in\r\n            \r\n            let oneHundredMB = 100 * 1024 * 1024\r\n            let shouldCompact = (totalBytes > oneHundredMB) && (Double(usedBytes) / Double(totalBytes)) < 0.5\r\n            \r\n            if shouldCompact {\r\n                LLAnalyticsManager.shared.track(event: \"APP_ShouldCompact\", properties: [\"TotalRealmBytes\" : totalBytes, \"UsedRealmBytes\" : usedBytes])\r\n            }\r\n            \r\n            return shouldCompact\r\n        })\r\n        \r\n        config.fileURL = userPath\r\n        config.schemaVersion = self.realmSchemaVersion\r\n        Realm.Configuration.defaultConfiguration = config\r\n        \r\n        // Each time the db is requested, check for overhead space.\r\n        // If there is not enough space, give a warning once per activity cycle\r\n        if let freeSpace = self.freeStorageMB {\r\n            if freeSpace < self.minimumFreeSpace {\r\n                if !self.hasShownStorageWarningThisWake {\r\n                    self.showStorageWarning()\r\n                    self.hasShownStorageWarningThisWake = true\r\n                }\r\n            }\r\n        }\r\n```"}}
{"actor":{"display_login":"bruce-lumo"}}