objectbox / objectbox/objectbox-dart

Issue running on on NixOS

Open
#548 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

Basic info:
  • ObjectBox version: objectbox: ^1.7.2, objectbox_flutter_libs: any, objectbox_generator: any
  • Flutter/Dart SDK: Flutter 3.10.0, Dart 3.0.0
  • Reproducible: Always
  • Build OS: NixOS 23.05 (Stoat)
  • Deployment device or OS: NixOS 23.05 (Stoat)
Steps to reproduce
  1. Build a project that uses objectbox_flutter_libs (or libobjectbox.so)
  2. Try to run it
  3. :(
Expected behavior

App would run

Code

N/A

Logs, stack traces
$ flutter run --device-id linux
{...}
flutter: Failed to load ObjectBox library. For Flutter apps, check if objectbox_flutter_libs is added to dependencies. For unit tests and Dart apps, check if the ObjectBox library was downloaded (https://docs.objectbox.io/getting-started).
flutter: Failed to load ObjectBox library. For Flutter apps, check if objectbox_flutter_libs is added to dependencies. For unit tests and Dart apps, check if the ObjectBox library was downloaded (https://docs.objectbox.io/getting-started).
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libobjectbox.so': libobjectbox.so: cannot open shared object file: No such file or directory
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12)
#2      _tryObjectBoxLibFile (package:objectbox/src/native/bindings/bindings.dart:84:29)
#3      loadObjectBoxLib (package:objectbox/src/native/bindings/bindings.dart:101:12)
#4      C (package:objectbox/src/native/bindings/bindings.dart:119:27)
#5      C (package:objectbox/src/native/bindings/bindings.dart)
#6      new Model (package:objectbox/src/native/model.dart:19:31)
#7      new Store (package:objectbox/src/native/store.dart:175:21)
#8      openStore (package:notes/objectbox.g.dart:90:5)
<asynchronous suspension>
#9      initStore (package:notes/store.dart:25:16)
<asynchronous suspension>
#10     main (package:notes/main.dart:10:3)
<asynchronous suspension>
$ ldd build/linux/arm64/debug/bundle/lib/libobjectbox.so 
        linux-vdso.so.1 (0x0000ffff86e80000)
        libdl.so.2 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libdl.so.2 (0x0000ffff86d00000)
        libstdc++.so.6 => not found
        libm.so.6 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libm.so.6 (0x0000ffff86c50000)
        libgcc_s.so.1 => /nix/store/x2f8wiip66lxf6zynscszpm4d990q098-xgcc-12.2.0-libgcc/lib/libgcc_s.so.1 (0x0000ffff86c10000)
        libpthread.so.0 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libpthread.so.0 (0x0000ffff86be0000)
        libc.so.6 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libc.so.6 (0x0000ffff86a30000)
        /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/ld-linux-aarch64.so.1 (0x0000ffff86e43000)
$ LD_LIBRARY_PATH=/nix/store/px2m9rmdcp245j1sdgdrhamlk6ph182b-gcc-12.2.0-lib/lib/ ldd build/linux/arm64/debug/bundle/lib/libobjectbox.so
        linux-vdso.so.1 (0x0000ffff9919b000)
        libdl.so.2 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libdl.so.2 (0x0000ffff99010000)
        libstdc++.so.6 => /nix/store/px2m9rmdcp245j1sdgdrhamlk6ph182b-gcc-12.2.0-lib/lib/libstdc++.so.6 (0x0000ffff98de0000)
        libm.so.6 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libm.so.6 (0x0000ffff98d30000)
        libgcc_s.so.1 => /nix/store/px2m9rmdcp245j1sdgdrhamlk6ph182b-gcc-12.2.0-lib/lib/libgcc_s.so.1 (0x0000ffff98cf0000)
        libpthread.so.0 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libpthread.so.0 (0x0000ffff98cc0000)
        libc.so.6 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libc.so.6 (0x0000ffff98b10000)
        /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/ld-linux-aarch64.so.1 (0x0000ffff9915e000)

To fix the issue I tried..

$ LD_LIBRARY_PATH=/nix/store/px2m9rmdcp245j1sdgdrhamlk6ph182b-gcc-12.2.0-lib/lib/ flutter run
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libobjectbox.so': libobjectbox.so: cannot open shared object file: No such file or directory

but it didn't work. I thought that the issue may be with flutter run overriding the LD_LIBRARY_PATH - so I've decided to test it another way:

$ flutter build linux
$ LD_LIBRARY_PATH=/nix/store/px2m9rmdcp245j1sdgdrhamlk6ph182b-gcc-12.2.0-lib/lib/ build/linux/arm64/debug/bundle/notes 
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libobjectbox.so': libobjectbox.so: cannot open shared object file: No such file or directory

But it still doesn't work

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure on NixOS 23.05 with the listed Flutter and Dart versions, using objectbox_flutter_libs and the Linux run command. Start in package:objectbox/src/native/bindings/bindings.dart and compare the bundled libobjectbox.so dependencies shown by ldd; done means the ObjectBox library loads and the app runs without a manual LD_LIBRARY_PATH workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter, nixos
Domain
databases, desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.