Closed w461 closed 1 year ago
Thanks for reporting! Can you share a minimal example of how your directory structure looks like so we can reproduce this?
The error message looks like the generator does not get any input.
Also fixed the typo in the docs.
Edit: double posted on Stack Overflow.
is tjhis sufficient?
myProject myProject/lib myProject/lib/pubspec.yaml myProject/packages/lib/objectbox-datamodel.dart myProject/packages/lib/libobjectbox.g.dart myProject/packages/lib/pubspec.yaml
pubspec.yaml
name: cleaningfairy_data
description: Data Sources for the Cleaning Fairy
version: 0.0.1
environment:
sdk: '>=2.18.4 <3.0.0'
flutter: ">=1.17.0"
dependencies:
cleaningfairy_domain:
path: ../domain
equatable: ^2.0.5
dartz: ^0.10.1
uuid: ^3.0.6
objectbox: ^1.6.2
objectbox_flutter_libs: any
dev_dependencies:
build_runner: ^2.3.2
build_web_compilers: ^3.0.0
json_serializable: ^6.3.1
test: ^1.21.4
mockito: ^5.3.0
objectbox_generator: any
flutter:
assets:
- assets/
Apologies, I did this too quickly while boarding the airplane... The structure should be (I added the data package)
myProject myProject/lib myProject/lib/pubspec.yaml myProject/packages/data/lib/objectbox-datamodel.dart myProject/packages/data/lib/libobjectbox.g.dart myProject/packages/data/lib/pubspec.yaml
I am running build_runner from the directory myProject/packages/data
Thanks! ObjectBox expects the recommended package structure. In your case pubspec.yaml
should exist above the lib
folder. If that's not it, I'll have to recreate your setup.
myProject
myProject/pubspec.yaml
myProject/lib
myProject/packages/data/pubspec.yaml
myProject/packages/data/lib/objectbox-datamodel.dart
myProject/packages/data/lib/libobjectbox.g.dart
Sorry for the inconvenience - another "typo". You are right, and my pubspec.yaml is (was) located at data/pubspec.yaml. So it must be something else
can you reproduce the issue?
I tried with a sub-package that is Dart only and one containing a Flutter dependency. Both work using dart run build_runner build
and flutter pub run build_runner build
respectively.
I remember seeing this error before, but I can't find anything related.
So sorry for wasting your efforts. I was using flutter pub run build_runner build
instead of dart run build_runner build
for my dart package. I had some other error initially and I guess with moving files to the parent flutter app, I always re-ran the flutter build command without thinking also for the dart package.
Now I receive the following [WARNING] objectbox_generator:generator on lib/$lib$: Failed to find package root from output directory, generated imports might be incorrect. [WARNING] No actions completed for 25.6s, waiting on:
Is there a different way than running the app to check if everything is fine?
The Failed to find package root from output directory, generated imports might be incorrect.
warning appears to be incorrectly printed if the output directory is the package source root directory (e.g. lib
). This will be fixed in an upcoming release.
However, at least in my test the generator still works fine.
1.7.0
is out which not longer prints the incorrect warning. It also prints the detected paths if it will detect an incorrect out path.
Use flutter pub upgrade
or dart pub upgrade
to update.
@w461 Let us know if you continue having issues.
Thanks Uwe. Issues stopped as soon as I did everything properly - works like a charm (for now)
I have separated the data (and domain) layer to packages underneath my project. Now if I take your
^
[INFO] Running build completed, took 3.9s
[INFO] Caching finalized dependency graph completed, took 529ms
[SEVERE] Failed after 4.5s`
User
example (by the way, it should end with}
not)
), I am able to run build_runner with an entity file in the project root lib. However, if I place the same file in the lib of the package, and run build_runner from the data package directory, I receive the following error:[SEVERE] objectbox_generator:generator on lib/$lib$:
`
FormatException: Unexpected end of input (at character 1)The dependencies are added to the data package yaml and I also see
libobjectbox.dylib
inside the lib directory of the data package from runningbash
.