解决proto文件生成dart失败的问题
背景:用了多年的电脑换新了,proto文件添加一个字段需要重新生成一下api.pb.dart文件。
在有api.proto的目录下执行命令
protoc --dart_out=. api.proto
报错如下:
protoc-gen-dart: program not found or is not executable Please specify a program using absolute path or make sure the program is available in your PATH system variable --dart_out: protoc-gen-dart: Plugin failed with status code 1.
看了.zshrc文件中环境变量配置如下:
export PATH="$PATH":"$HOME/.pub-cache/bin"
去pub-cache目录里看了一下眼并没有bin目录,应该是flutterSDK从inter换成arm时被清空了。
于是重新安装protoc_plugin,安装命令如下:
flutter pub global activate protoc_plugin
等待安装完成,再次执行生成命令就成功了。