Buf cannot resolve dependencies when we use workspaces
Hi, team 👋 Thank you so much for your kind support. We just recently started using buf, but one problem we face is if we use a workspace that depends on another workspace, buf seems to fail to resolve the dependencies. I've created a repository to reproduce the problem.
- https://github.com/shuheiktgw/buf-test
If you run buf generate at the root, it seems buf fails to resolve the dependency to google/rpc/code.proto. Would you guide us on what is wrong with our configuration? I found a similar issue, https://github.com/bufbuild/buf/issues/687, but it just stopped using a workspace to avoid the issue.
buf generate
proto_deps/shuheiktgw/test1/v1/message.proto:6:8:google/rpc/code.proto: does not exist
I'm currently using buf 1.27.1.
buf --version
1.27.1
Thanks, in advance!
OK, I think I've finally figured out what was wrong with the configuration (but let me leave it open to confirm if my understanding is correct). What I needed to do was
- Create a buf.build/shuheiktgw/test1 repository, and push the latest changes to create a commit
- Declear the following dependencies in proto/buf.yaml and run
buf mod updateto create buf.lock
+deps:
+ - buf.build/shuheiktgw/test1
Then buf generate at the root works just fine. I thought workspaces work fine without creating actual repositories, but IIUC, buf needs them to create a correct buf.lock and resolve dependencies.
Hey @shuheiktgw, I can confirm that your solution is correct. We're looking to improve the behavior in the future.
Hi, so this behaviour is greatly improved for v2 modules and workspaces: https://buf.build/docs/configuration/v2/buf-yaml
Dependencies for v2 workspaces is now defined across the entire workspace, so it should make it much easier to resolve.
Going to close this since migrating to v2 should address this issue, migration guide available here: https://buf.build/docs/migration-guides/migrate-v2-config-files. Please feel free to re-open if there are questions and/or concerns!