Skip to content

[dargon2] Unable to load dynamic libraries with compiled native Dart project #17

Open
@jagandeepbrar

Description

@jagandeepbrar

It appears that compiling to a native Dart binary will cause the library to fail to load.

When using dart run there is no issue with utilizing the library and all functionality can complete as expected, but when first using dart compile exe <file> and running the generated binary directly, the library is unable to be loaded.

Null check operator used on a null value
#0      DartLibLoader.getPath (package:dargon2/src/native/dart_lib_loader.dart:34)
#1      DartLibLoader.loadLib (package:dargon2/src/native/dart_lib_loader.dart:24)
#2      new LocalBinder._ (package:dargon2_core/src/native/local_binder.dart:155)
#3      LocalBinder.initialize (package:dargon2_core/src/native/local_binder.dart:130)
#4      new DArgon2Native (package:dargon2_core/src/native/dargon2_native.dart:17)
#5      argon2 (package:dargon2/src/argon2.dart:11)

This is occurring because the dynamic library loader is currently using the package path to find the required blobs/dynamic libraries, which is not always found on the host machine (we should be able to expect compiled Dart code to execute without the Dart SDK or packages).

I have a workaround by using dargon2_core directly and creating my own DynamicLibrary loader by shipping the compiled binary with the required blobs, but wanted to validate that there isn't another way to allow compiled Dart binaries to load the library directly from the dargon2 package.

Details:

  • Host: MacOS 13.2.1 (ARM)
  • Dart: 3.0.0-322.0.dev (dev) (Fri Mar 10 06:41:16 2023 -0800) on "macos_arm64"
  • Package: 3.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions