drift icon indicating copy to clipboard operation
drift copied to clipboard

Error: Method not found: 'BaseReferences'.

Open BrijalKothari opened this issue 1 year ago • 3 comments

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

BrijalKothari avatar Aug 23 '24 20:08 BrijalKothari

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:

  • Making sure you're not on drift_dev version 2.20.x and re-running build_runner build to generate code compatible with drift version 2.19.x.
  • Upgrading drift to 2.20.0 and keeping the generated code unchanged.

simolus3 avatar Aug 24 '24 13:08 simolus3

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

orestesgaolin avatar Sep 04 '24 13:09 orestesgaolin

This is because of conflicting versions of drift. I had to get into pub-cache (~/.pub-cache/hosted/pub.dev/) and manually delete the older versions of drift.

srix55 avatar Sep 26 '24 13:09 srix55