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

Create an example for compiling and deploying a Dart-only app that uses realm #1755

Closed
KhaledBasiony opened this issue Jul 21, 2024 · 4 comments

Comments

@KhaledBasiony
Copy link

KhaledBasiony commented Jul 21, 2024

Problem

I don't know how to compile the application as an executable and distribute it.

I have a dart-only server that uses realm,
previously I was on version 1.9.0 and when trying to compile it, it was complaining about the plugin library being accessed outside of flutter (I am sure I was using realm_dart package)

now I upgraded to 3.3.0, hoping that would solve the problem, but now It depends on .dart_tools/package_config.json

Bad state: Could not find package_config.json
#0      _getPackageConfigJson (package:realm_dart/src/handles/native/init.dart:78)
#1      _openRealmLib (package:realm_dart/src/handles/native/init.dart:114)
#2      initRealm (package:realm_dart/src/handles/native/init.dart:157)

I don't know what I am supposed to do now

Solution

I was hoping you could provide a section in the docs or quick start or something to show how to compile/deploy a server or a CLI application step-by-step

Alternatives

No response

How important is this improvement for you?

Dealbreaker

Feature would mainly be used with

Atlas Device Sync

Copy link

sync-by-unito bot commented Jul 21, 2024

➤ PM Bot commented:

Jira ticket: RDART-1074

@nielsenko
Copy link
Contributor

nielsenko commented Jul 31, 2024

@KhaledBasiony Sorry about that - you hit a bug.

We need to find the native shared library for the realm database. One way we do that is to read and parse the .dart_tools/package_config.json file. If you compile your application to an exe file and copy it outside the project directory, it cannot find package_config.json. Obviously this should not fail the process (hence the bug), instead we should try to load the lib from elsewhere.

Since the native assets feature is not stable (yet), you will be required to manually bundle the shared lib with your application. Unlike flutter, we cannot hook into the build process for pure dart.

@KhaledBasiony
Copy link
Author

KhaledBasiony commented Jul 31, 2024

@nielsenko
Thanks for the reply, I worked around it for now, by providing the shared library file and a dummy .dart_tools/package_config.json + a dummy pubspec.yaml with the release (which is obviously not ideal, but meh)

this is necessary because _openRealmLib calls _getPackageConfigJson Before asking OS to provide the shared library file, so even if the shared library exists in PATH, .dart_tools/package_config.json must still be there too.

@nielsenko
Copy link
Contributor

@KhaledBasiony You asked for an example, but since you have already made it work (even if it required a work-around, due to #1766, which is being addressed ), we have decided not to do an example for now.

People who use realm with pure dart outside flutter, are few and far apart, and the experience will be much improved once native assets lands.

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

No branches or pull requests

2 participants