dart-backend / angel

A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://github.com/dukefirehawk/angel
BSD 3-Clause "New" or "Revised" License
171 stars 22 forks source link

[Bug] angel3_orm_generator not working (Failed to precompile build script .dart_tool/build/entrypoint/build.dart) #88

Closed ynnob closed 1 year ago

ynnob commented 1 year ago

Error build_runner:

PS C:\Users\X\Documents\repos\helltax\database> dart run build_runner build --delete-conflicting-outputs
[INFO] Generating build script completed, took 306ms
[WARNING] ../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/angel3_orm_generator-7.1.0/lib/src/orm_build_context.dart:460:32: Error: The type 'PropertyAccessorElement?' of the getter 'RelationFieldImpl.getter' is not a subtype of the type 'PropertyAccessorElementImpl?' of the inherited setter 'PropertyInducingElementImpl.getter'.
 - 'PropertyAccessorElement' is from 'package:analyzer/dart/element/element.dart' ('../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-5.3.1/lib/dart/element/element.dart').
 - 'PropertyAccessorElementImpl' is from 'package:analyzer/src/dart/element/element.dart' ('../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-5.3.1/lib/src/dart/element/element.dart').
  PropertyAccessorElement? get getter => originalField.getter;
                               ^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-5.3.1/lib/src/dart/element/element.dart:5789:32: Context: This is the declaration of the setter 'PropertyInducingElementImpl.getter'.
  PropertyAccessorElementImpl? getter;
                               ^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/angel3_orm_generator-7.1.0/lib/src/orm_build_context.dart:460:32: Error: The return type of the method 'RelationFieldImpl.getter' is 'PropertyAccessorElement?', which does not match the return type, 'PropertyAccessorElementImpl?', of the overridden method, 'PropertyInducingElementImpl.getter'.
 - 'PropertyAccessorElement' is from 'package:analyzer/dart/element/element.dart' ('../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-5.3.1/lib/dart/element/element.dart').
 - 'PropertyAccessorElementImpl' is from 'package:analyzer/src/dart/element/element.dart' ('../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-5.3.1/lib/src/dart/element/element.dart').
Change to a subtype of 'PropertyAccessorElementImpl?'.
  PropertyAccessorElement? get getter => originalField.getter;
                               ^
../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-5.3.1/lib/src/dart/element/element.dart:5789:32: Context: This is the overridden method ('getter').
  PropertyAccessorElementImpl? getter;
                               ^
[INFO] Precompiling build script... completed, took 792ms
[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.

Setup

models.dart

import 'package:angel3_migration/angel3_migration.dart';
import 'package:angel3_model/angel3_model.dart';
import 'package:angel3_orm/angel3_orm.dart';
import 'package:angel3_serialize/angel3_serialize.dart';
import 'package:optional/optional.dart';
part 'models.g.dart';

@orm
@serializable
abstract class _User extends Model {
  String get email;
  String get passwordHash;
  bool? get emailConfirmed;
}

pubspec.yaml

dependencies:
  angel3_migration_runner: ^7.0.0
  angel3_orm: ^7.0.1
  angel3_orm_postgres: ^7.0.1
  collection: ^1.15.0
  optional: ^6.0.0
  postgres: ^2.5.2
  uuid: ^3.0.7

dev_dependencies:
  angel3_orm_generator: ^7.1.0
  build_runner: ^2.0.0
  lints: ^2.0.0
  test: ^1.22.1

Note

When forking angel3 and resolving all packages the error exists in orm_build_context.dart:

[{
    "resource": "/c:/Users/X/Documents/repos/contribution/angel/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart",
    "owner": "_generated_diagnostic_collection_name_#1",
    "code": {
        "value": "invalid_override",
        "target": {
            "$mid": 1,
            "external": "https://dart.dev/diagnostics/invalid_override",
            "path": "/diagnostics/invalid_override",
            "scheme": "https",
            "authority": "dart.dev"
        }
    },
    "severity": 8,
    "message": "'RelationFieldImpl.getter' ('PropertyAccessorElement? Function()') isn't a valid override of 'PropertyInducingElementImpl.getter' ('PropertyAccessorElementImpl? Function()').",
    "source": "dart",
    "startLineNumber": 460,
    "startColumn": 32,
    "endLineNumber": 460,
    "endColumn": 38,
    "relatedInformation": [
        {
            "startLineNumber": 5789,
            "startColumn": 32,
            "endLineNumber": 5789,
            "endColumn": 38,
            "message": "The member being overridden.",
            "resource": "/C:/Users/X/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-5.3.1/lib/src/dart/element/element.dart"
        }
    ]
}]

While the setup above fails, the following dependencies can generate models as expected:

dependencies:
  angel3_migration_runner: ^6.1.0
  angel3_orm: ^6.0.0
  angel3_orm_postgres: ^6.1.0
  collection: ^1.15.0
  optional: ^6.0.0
  postgres: ^2.5.2
  uuid: ^3.0.7

dev_dependencies:
  angel3_orm_generator: ^6.0.0
  build_runner: ^2.0.0
  lints: ^2.0.0
  test: ^1.22.1
dukefirehawk commented 1 year ago

We will take a look. Are you using Dart 2.18 ?

ynnob commented 1 year ago

We will take a look. Are you using Dart 2.18 ?

Yes:

dukefirehawk commented 1 year ago

Found the problem. It is caused by analyzer:5.3.x. There is an unknown change that break the code that works up to analyzer:5.2.x. We have released angel3_orm_generator:7.1.1 as a temporary fix to lock the analyzer into 5.2.x. This is an ugly fix but necessary to allow more time to figure out how to fix the problem as there is nothing in the change log about this change. Just use angel3_orm_generator: ^7.1.1 to force analyzer 5.2.x to be used for the moment. Thanks for reporting it.

ynnob commented 1 year ago

Found the problem. It is caused by analyzer:5.3.x. There is an unknown change that break the code that works up to analyzer:5.2.x. We have released angel3_orm_generator:7.1.1 as a temporary fix to lock the analyzer into 5.2.x. This is an ugly fix but necessary to allow more time to figure out how to fix the problem as there is nothing in the change log about this change. Just use angel3_orm_generator: ^7.1.1 to force analyzer 5.2.x to be used for the moment. Thanks for reporting it.

Thanks for the fast response! This is indeed weird that they didn't announce a change for that version.

dukefirehawk commented 1 year ago

The issue with analyzer:5.3.x is fixed in angel_orm_generator:7.1.2.

kevinelliott commented 1 year ago

Because aggregation_server depends on angel3_serialize_generator ^7.1.1 which doesn't match any versions, version solving failed.

kevinelliott commented 1 year ago

Because aggregation_server depends on angel3_serialize_generator ^7.1.2 which doesn't match any versions, version solving failed.

kevinelliott commented 1 year ago

Is there a 7.1.1 and 7.1.2 release that I'm missing to find?

dukefirehawk commented 1 year ago

Have you tried with angel3_serialize_generator 7.0.0? Only angel3_orm_generator need to be updated to 7.1.2 to fix the analyzer issue. angel3_serialize_generator is not affected, hence no new release.

kevinelliott commented 1 year ago

Thanks @dukefirehawk let me take a look and try.

kevinelliott commented 1 year ago

@dukefirehawk That worked. I have verified it's fix for me. Thank you!