simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.55k stars 364 forks source link

Error: Method not found: 'BaseReferences'. #3172

Open BrijalKothari opened 3 weeks ago

BrijalKothari commented 3 weeks ago

I am using drift: ^2.19.1+1 and drift_dev: ^2.19.1 version i get below given error

Error: Method not found: 'BaseReferences'.

Future<void> validateDatabaseSchema(GeneratedDatabase database) async {
                                    ^^^^^^^^^^^^^^^^^
Error: Compilation failed.
  Command: D:\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev D:\flutter\bin\cache\dart-sdk\bin\snapshots\dart2js.dart.snapshot --platform-binaries=D:\flutter\bin\cache\flutter_web_sdk\kernel --invoker=flutter_tool     
  -Ddart.vm.product=true -DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/55eae6864b296dd9f43b2cc7577ec256e5c32a8d/ -DFLUTTER_WEB_AUTO_DETECT=false -DFLUTTER_WEB_USE_SKIA=false --native-null-assertions        
  --no-source-maps -o E:\elaunch projects\leylix-flutter\.dart_tool\flutter_build\a913532f8543273f5c68b3d2a8e67ace\app.dill --packages=.dart_tool/package_config.json --cfe-only E:\elaunch
  projects\leylix-flutter\.dart_tool\flutter_build\a913532f8543273f5c68b3d2a8e67ace\main.dart
simolus3 commented 3 weeks ago

This appears to be similar to https://github.com/simolus3/drift/issues/3168 and https://github.com/simolus3/drift/issues/3163.

Basically, it looks like your code has been generated by drift_dev version 2.20.0 but is running against drift version 2.19.x. I don't exactly understand how that's possible since drift_dev has a dependency on the same minor drift version, but I think you can fix it by either:

orestesgaolin commented 1 week ago

This is possible if database code is in the local package.

My main app resolves its drift_dev version to 2.19.1 until I forcefully run pub get despite my package using 2.20.1. In my case it couldn't update drift_dev version automatically as some other package depends on web <0.6.0.

App: screenshot_20240904_150836

Package: screenshot_20240904_150928