Issues with unit testing using Realm: Failed to Load Dynamic Library Error

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      What happened?

      I'm encountering persistent errors when attempting to run unit tests. Following an upgrade to Realm 2.0.0, the tests fail to execute, consistently yielding the following error:

      Realm error : Invalid argument(s): Failed to load dynamic library 'librealm_dart.dylib': dlopen(librealm_dart.dylib, 0x0001): tried: 'librealm_dart.dylib' (no such file), 
      ...
      LateInitializationError: Local 'realm' has not been initialized.
      dart:_internal           LateError._throwLocalNotInitialized
      

      This issue seems to recur with every Realm upgrade, but previously, I managed to resolve it. Could you please provide guidance on how to address this error? Additionally, I would greatly appreciate any advice on best practices for upgrading Realm in a manner that does not affect unit tests (increasing the version in pubspec.yaml usually breaks unit tests).

      Repro steps

      flutter test

      Version

      3.3.3/3.19.5

      What Atlas Services are you using?

      Local Database only

      What type of application is this?

      Flutter Application

      Client OS and version

      macOS 14.2.1

      Code snippets

      void main() {
      late Realm realm;

      test("Open a local realm", ()

      { realm = Realm(Configuration.local([Car.schema])); expect(realm.isClosed, isFalse); }

      );

      tearDown(()

      { realm.close(); }

      );
      }

      Stacktrace of the exception/crash you're getting

      No response

      Relevant log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Realm error : Invalid argument(s): Failed to load dynamic library 'librealm_dart.dylib': dlopen(librealm_dart.dylib, 0x0001): tried: 'librealm_dart.dylib' (no such file), 
      ...
      LateInitializationError: Local 'realm' has not been initialized.
      dart:_internal           LateError._throwLocalNotInitialized
      

              Assignee:
              Kasper Nielsen (Inactive)
              Reporter:
              Unito Sync Bot
              Archiver:
              Marc Greenfield

                Created:
                Updated:
                Archived: