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

Cannot find generated *.realm.dart files after dart run realm generate #1823

Closed
HeavySnowJakarta opened this issue Jan 17, 2025 · 3 comments
Closed

Comments

@HeavySnowJakarta
Copy link

What happened?

The script succeeds after dart run realm generate:

> dart run realm generate
Building package executable...
Built realm:realm.
[INFO] Generating build script...
[INFO] Generating build script completed, took 341ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 301ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 1.2s

[INFO] Running build...
[INFO] Running build completed, took 46ms

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 146ms

[INFO] Succeeded after 202ms with 0 outputs (0 actions)

It seems the result has been cached because it has succeeded before, but I could never find the needed file (after any ever generations).

No file at the same directory with the source file, no file at other related directories, and even no file can be searched with Everything.

Repro steps

At pubspec.yaml:

  # Reaml used for the noSQL database.
  realm: ^20.0.1

No build.yaml file found.

Run the generate at the root path (of the project) shows succeeded with actually no file generated. The script rejects to work at the same directory with the sources needed to be dealed with (with the error Error parsing package pubspec at Directory: '.'. Error PathNotFoundException: Cannot open file, path = 'pubspec.yaml').

Confirms there is nothing wrong with permissions to write with the command touch element.realm.dart and del element.realm.dart.

Confirms that the files are really not created with Explorer.

There is no error with dart run build_runner build --delete-conflicting-outputs:

>  dart run build_runner build --delete-conflicting-outputs
Building package executable... (9.2s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 504ms
[INFO] Reading cached asset graph completed, took 312ms
[INFO] Checking for updates since last build completed, took 1.4s
[INFO] Running build completed, took 61ms
[INFO] Caching finalized dependency graph completed, took 259ms
[INFO] Succeeded after 330ms with 0 outputs (0 actions)

Now there is no *.realm.dart. My conclusion is it's VERY WEIRD.

Version

Flutter 3.24.1 • channel stable • Dart 3.5.1 • DevTools 2.37.2

What Atlas Services are you using?

Local Database only

What type of application is this?

Flutter Application

Client OS and version

Windows 11 23H2 22631.4751

Code snippets

// Realm models for frequencies.
@RealmModel()
class _Freq{
  late double value;
  late String unit;
}

// Realm models for time zones.
@RealmModel()
class _TimeZone{
  late String locationStr;
}

Stacktrace of the exception/crash you're getting

No stacktrace. It reported success.

Here is the outputs of a clean build:

Relevant log output

>  dart run realm generate --watch
Building package executable...
Built realm:realm.
[INFO] Generating build script...
[INFO] Generating build script completed, took 630ms

[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 10.3s

[INFO] Setting up file watchers...
[INFO] Setting up file watchers completed, took 43ms

[INFO] Waiting for all file watchers to be ready...
[INFO] Waiting for all file watchers to be ready completed, took 646ms

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 7.4s

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 3ms

[INFO] Running build...
[INFO] 1.3s elapsed, 0/16 actions completed.
[INFO] 2.4s elapsed, 0/26 actions completed.
[INFO] 3.4s elapsed, 3/33 actions completed.
[INFO] 4.6s elapsed, 5/35 actions completed.
[INFO] 5.6s elapsed, 6/36 actions completed.
[INFO] 6.8s elapsed, 8/37 actions completed.
[INFO] 8.3s elapsed, 9/38 actions completed.
[INFO] 9.4s elapsed, 10/40 actions completed.
[INFO] 10.8s elapsed, 14/41 actions completed.
[INFO] 11.9s elapsed, 16/42 actions completed.
[INFO] 13.0s elapsed, 22/47 actions completed.
[INFO] 14.0s elapsed, 24/49 actions completed.
[INFO] 15.1s elapsed, 26/50 actions completed.
[INFO] 16.1s elapsed, 27/53 actions completed.
[INFO] 17.2s elapsed, 29/54 actions completed.
[INFO] 18.2s elapsed, 32/55 actions completed.
[INFO] 19.2s elapsed, 32/56 actions completed.
[INFO] 20.3s elapsed, 35/58 actions completed.
[INFO] 21.3s elapsed, 40/59 actions completed.
[INFO] 22.5s elapsed, 40/60 actions completed.
[INFO] 23.5s elapsed, 41/64 actions completed.
[INFO] 24.6s elapsed, 45/65 actions completed.
[INFO] 25.6s elapsed, 45/66 actions completed.
[INFO] 26.6s elapsed, 46/67 actions completed.
[INFO] 27.6s elapsed, 53/72 actions completed.
[INFO] 1m 6s elapsed, 64/81 actions completed.
[WARNING] No actions completed for 38.4s, waiting on:
  - build_resolvers:transitive_digests on package:flutter_test/flutter_test.dart
  - json_serializable on test/widget_test.dart
  - json_serializable on lib/layouts/mobile/pages/about/page.dart
  - json_serializable on lib/layouts/mobile/app.dart
  - json_serializable on lib/layouts/mobile/pages/entry_edit/form.dart
  .. and 12 more

[INFO] 1m 9s elapsed, 64/82 actions completed.
[INFO] 1m 10s elapsed, 72/91 actions completed.
[INFO] 1m 11s elapsed, 95/102 actions completed.
[INFO] 1m 13s elapsed, 106/109 actions completed.
[INFO] 1m 17s elapsed, 109/110 actions completed.
[INFO] realm:realm_generator on test/widget_test.dart:[generate (0)] completed, took 91ms
[INFO] realm:realm_generator on lib/config/contact_modes.dart:[generate (0)] completed, took 101ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/about/page.dart:[generate (0)] completed, took 157ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/entry_edit/controller.dart:[generate (0)] completed, took 161ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/entry_edit/form.dart:[generate (0)] completed, took 135ms
[INFO] realm:realm_generator on lib/layouts/mobile/app.dart:[generate (0)] completed, took 148ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/entry_list/create.dart:[generate (0)] completed, took 175ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/entry_edit/page.dart:[generate (0)] completed, took 191ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/entry_list/controller.dart:[generate (0)] completed, took 226ms
[INFO] realm:realm_generator on lib/config/default_modes_for_logbooks.dart:[generate (0)] completed, took 231ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/data.dart:[generate (0)] completed, took 237ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/custom_field.dart:[generate (0)] completed, took 296ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/default_custom_fields/page.dart:[generate (0)] completed, took 328ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/entry_list/page.dart:[generate (0)] completed, took 365ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/default_custom_fields/controller.dart:[generate (0)] completed, took 387ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/form.dart:[generate (0)] completed, took 449ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/manager.dart:[generate (0)] completed, took 71ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/usually_used_modes/controller.dart:[generate (0)] completed, took 106ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/usually_used_modes/custom_modes.dart:[generate (0)] completed, took 133ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/usually_used_modes/page.dart:[generate (0)] completed, took 119ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_edit/page.dart:[generate (0)] completed, took 151ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_select/create.dart:[generate (0)] completed, took 172ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_select/find_logbooks.dart:[generate (0)] completed, took 188ms
[INFO] realm:realm_generator on lib/shared/debug/logger.dart:[generate (0)] completed, took 193ms
[INFO] realm:realm_generator on lib/shared/exceptions/page_building.dart:[generate (0)] completed, took 200ms
[INFO] realm:realm_generator on lib/shared/exceptions/storation.dart:[generate (0)] completed, took 214ms
[INFO] realm:realm_generator on lib/layouts/mobile/pages/logbook_select/page.dart:[generate (0)] completed, took 251ms
[INFO] realm:realm_generator on lib/shared/translation/total.dart:[generate (0)] completed, took 261ms
[INFO] realm:realm_generator on lib/shared/translation/zh_cn.dart:[generate (0)] completed, took 267ms
[INFO] realm:realm_generator on lib/main.dart:[generate (0)] completed, took 274ms
[INFO] realm:realm_generator on lib/shared/widgets/double_string_field.dart:[generate (0)] completed, took 304ms
[INFO] realm:realm_generator on lib/shared/widgets/jump_page_button.dart:[generate (0)] completed, took 50ms
[INFO] realm:realm_generator on lib/shared/widgets/single_string_field.dart:[generate (0)] completed, took 85ms
[INFO] realm:realm_generator on lib/storation/element.dart:[generate (0)] completed, took 297ms
[INFO] realm:realm_generator on lib/storation/log_media.dart:[generate (0)] completed, took 330ms
[WARNING] realm:realm_generator on lib/storation/element.dart:
element.realm.dart must be included as a part directive in the input library with:
    part 'element.realm.dart';
[INFO] realm:realm_generator on lib/storation/logbook.dart:[generate (0)] completed, took 466ms
[INFO] Running build completed, took 1m 19s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 304ms

[INFO] Succeeded after 1m 20s with 74 outputs (256 actions)
@nirinchev
Copy link
Member

The issue is reported as a warning here:

[WARNING] realm:realm_generator on lib/storation/element.dart:
element.realm.dart must be included as a part directive in the input library with:
    part 'element.realm.dart';

Essentially, you're missing the expression to include the generated code into your element.dart, which tells the generator it you don't want to generate it.

@HeavySnowJakarta
Copy link
Author

that's it. i thought it warned because i must add it to the file after the generation.

@nirinchev
Copy link
Member

Yeah, it's a bit of an annoying chicken and egg problem, where you need to add part ... for the generator to generate the file, but you need the generated file so that part ... doesn't get flagged as a compilation error 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants