buf icon indicating copy to clipboard operation
buf copied to clipboard

buf generate failed: may find the wrong file location

Open kettlecat6 opened this issue 3 years ago • 3 comments

Hi all: I'm using buf for a long time, thanks to all of you guys first, you did great job!

What version of protobuf and what language are you using? Protoc Version: 3.21.12

Language: Go

Buf Version: v1.5.0-v1.8.0 good, v1.9.0+ bad for me

What operating system (Linux, Windows, ...) and version? macOS Ventura 13.1 (ARM)

What did you do?

  1. Upgrade buf binary version from v1.5.0 into v1.9.0+(tried all of them,and didn't work correctly)
  2. Manually cleaned buf mod caches
  3. buf generate
  4. An error occurred

What did you expect to see Generate successfully What did you see instead?

Failure: lstat /Users/{me}/.cache/buf/v1/module/data/buf.build/googleapis/googleapis/783e4b5374fa488ab068d08af9658438/license/v1/license.proto: not a directory

license/v1/license.proto does not exist under 783e4b5374fa488ab068d08af9658438

Anything else we should know about your project / environment

I have a proto repository which contains 20+ grpc services, one of them named 'license', buf binary compiled all of them correctly before upgrade, which is tagged at 'v1.5.0'

What I tried:

  • buf binary test: v1.9.0+ buf generate will be failed
  • clean cache and regenerate: not work for me, buf generate is still failed
  • buf mod update: update success, buf generate is still failed
  • downgrade to 1.5.0--1.8.0: success

So I tagged buf binary at v1.8.0 for now. Warning showed when I generate codes the first time downgraded:

WARN    Module "buf.build/googleapis/googleapis:783e4b5374fa488ab068d08af9658438" has invalid cache state: calculated digest "b3-hcFCg87bpXHNQCxiHX_O0mQwbtnjzbAJfn67keq9f5w=" does not match stored digest "b3-_gBFYlSqszGZv7x8W3c9k0-R-2Xfr_nS3OV4QYwdkQQ=". The cache will attempt to self-correct.

What I have:

I do have a service named licnese, and here's a piece of code:

//file path: proto/license/v1/license.proto

syntax = "proto3";

package license.v1;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";

option go_package = "git.{xxx}.com/ms-public/sdk-grpc/langs/go/pb/license/v1";

service LicenseService {
  rpc GetAuthorizedOS(google.protobuf.Empty) returns (GetAuthorizedOSResponse) {
    option (google.api.http) = {
      get: "/license/v1/authorized_os"
    };
  }
  // ...
}

// messages below does not use any google-packages
// ...

What I think:

  • Is buf trying to find 'license/v1/license.proto' in googleapis?
  • What does the WARN means? is buf(v1.9.0+) downloads wrong packages?

kettlecat6 avatar Jan 11 '23 03:01 kettlecat6

Hey @kettlecat6 ~I wasn't able to replicate this issue~. I have an example repo here that puts all of the files where you've described

├── buf.gen.yaml
├── buf.lock
├── buf.yaml
├── gen
│   └── proto
│       └── go
│           └── proto
│               └── license
│                   └── v1
│                       └── license.pb.go
└── proto
    └── license
        └── v1
            └── license.proto

~I have run buf generate on both v1.8.0 v1.9.0 and v1.10.0 and they have all worked:~

buf --version 
1.8.0
➜  buf-1723 git:(master) buf generate

buf --version
1.9.0
➜  buf-1723 git:(master) buf generate

buf --version 
1.10.0
➜  buf-1723 git:(master) buf generate

~Would you be able to verify that this repo has all of the elements that is causing buf to fail for you?~

Edit: was able to replicate it. will bring back to team

joshcarp avatar Jan 11 '23 20:01 joshcarp

Hi guys, any progress about this issue?

kettlecat6 avatar Mar 15 '23 03:03 kettlecat6

@joshcarp, I was looking to verify whether this is still reproducible with the latest version, but wasn't able to reproduce with either 1.26.1 or 1.9.0 with your repository. Was there an additional step necessary to reproduce?

timostamm avatar Sep 12 '23 15:09 timostamm

Closing as we are unable to reproduce, but feel free to re-open if a reproduction can be provided with the latest version of buf!

bufdev avatar Jun 14 '24 00:06 bufdev