buf icon indicating copy to clipboard operation
buf copied to clipboard

`buf dep update` returns `file does not exist` error

Open aK0nshin opened this issue 1 year ago • 1 comments

Hello, I've just wanted to use Decimal type from googleapis, but I stuck with fetching dependency with buf dep update.

My project structure is:

$ tree
.
├── buf.gen.yaml
├── buf.lock
├── gen
│   └── go
│       └── my_project_proto
│           └── v1
│               ├── main_grpc.pb.go
│               └── main.pb.go
├── go.mod
├── go.sum
├── README.md
└── my_project_proto
    └── v1
        ├── buf.yaml
        └── main.proto

My my_project_proto/v1/buf.yaml looks like this:

version: v1
breaking:
  use:
    - FILE
lint:
  use:
    - DEFAULT
deps:
  - buf.build/googleapis/googleapis

my_project_proto/v1/main.proto

syntax = "proto3";

package my_project_proto.v1;

import "google/type/decimal.proto";

service DummyService {
  rpc DummyAction(DummyActionRequest) returns (DummyActionResponse);
}

message DummyActionRequest {
  string dummy_str = 1;
}

message DummyActionResponse {
  string dummy_str = 1;
  string dummy_addition = 2;
}

When I try to fetch googleapis.

$ buf dep update
my_project_proto/v1/main.proto:5:8:import "google/type/decimal.proto": file does not exist

If I remove import "google/type/decimal.proto"; line from my_project_proto/v1/main.proto buf dep update finishes successfully, but resulting this empty buf.lock:

# Generated by buf. DO NOT EDIT.
version: v1

buf version I am using is: 1.32.1

Please, let me know, if I am doing something wrong.

aK0nshin avatar May 23 '24 15:05 aK0nshin

I'm unable to reproduce this issue with buf v1.32.1 - when I copy that buf.yaml and that .proto file, and then run buf dep update, the command succeeds, and the buf.lock has the correct contents:

# Generated by buf. DO NOT EDIT.
version: v1
deps:
  - remote: buf.build
    owner: googleapis
    repository: googleapis
    commit: 4383c33e6c714f8bb30a26a6d838e217
    digest: shake256:de26a277fc28b8b411ecf58729d78d32fcf15090ffd998a4469225b17889bfb51442eaab04bb7a8d88d203ecdf0a9febd4ffd52c18ed1c2229160c7bd353ca95

Can you create a reproducible example in i.e. a temporary github repository, with the commands for us to run to reproduce the issue?

bufdev avatar May 23 '24 15:05 bufdev

https://github.com/aK0nshin/buf-error-example

Got it with docker image:

$ docker run -v ${PWD}:/workdir buf-error-example
dummy_proto/v1/main.proto:5:8:import "google/type/decimal.proto": file does not exist

aK0nshin avatar May 27 '24 13:05 aK0nshin

Your buf.yaml should be at the root of your repository, not in dummy_proto.

bufdev avatar May 27 '24 13:05 bufdev

Yay! Thank you, it works. Seems like this situation needs a proper error message from cli tool.

aK0nshin avatar May 27 '24 13:05 aK0nshin

The docs explain this pretty thoroughly, but thanks for suggestion.

bufdev avatar May 27 '24 13:05 bufdev

buf.build/googleapis/googleapis

A lot of protobuf file are missing

reatang avatar Nov 05 '24 08:11 reatang