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

[protoc_plugin] Error The method '$_clearField' isn't defined for the class 'DartMixin'. #922

Open
jonasbadstuebner opened this issue Mar 13, 2024 · 2 comments

Comments

@jonasbadstuebner
Copy link

dart pub global activate -sgit https://github.com/google/protobuf.dart.git --git-path protoc_plugin/
gives me the following error:

* protoc_plugin 22.0.0-dev from git https://github.com/google/protobuf.dart.git at b76135 in protoc_plugin (was 21.1.2)                                                                                                                                                                                                   
Building package executables...                                                                                                                                                                                                                                                                                           
Failed to build protoc_plugin:protoc_plugin:                                                                                                                                                                                                                                                                              
../../../../../../.pub-cache/git/protobuf.dart-b7613581d847e1e36e76f0e36db3a412d8fea5b1/protoc_plugin/lib/src/generated/dart_options.pb.dart:85:23: Error: The method '$_clearField' isn't defined for the class 'DartMixin'.

ref is b761358

Dart SDK version: 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "linux_x64"

dart pub global activate -sgit https://github.com/google/protobuf.dart.git --git-path protoc_plugin --git-ref 1822b81df565f7b7d54450b33fa2c997f69a9995 works as expected, so the problem is somewhere in b761358

Am I missing something or is this a newly introduced problem?

@osa1
Copy link
Member

osa1 commented Mar 30, 2024

protoc_plugin in b761358 can only be compiled with the protobuf in the same commit (or later). Since we don't override the protobuf dependency to ../protobuf (I don't even know if that's possible when running dart pub global activate ...) it's trying to use the latest released protobuf library, which is not compatible.

Things to fix:

  • The commit forgot to bump protobuf dependency version. We should bump it to 4.0.0.
    After that the command will fail because 4.0.0 is not published yet.

  • If possible, override protobuf dependency to ../protobuf when installing from the git repo, because that's the only way to make sure it will always work. However I'm not sure if this is possible.

Note that after the second step above your project may fail to compile unless you also use the protobuf library from the git repo with the same rev as the protoc_plugin.

@jonasbadstuebner
Copy link
Author

By the way, it works on master.

Is there an ETA for 4.0.0, so I don't have to use a local repository?

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

No branches or pull requests

2 participants