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

Migration problems cannot generate protos any longer #1337

Closed
go-aegian opened this issue Nov 21, 2024 · 8 comments
Closed

Migration problems cannot generate protos any longer #1337

go-aegian opened this issue Nov 21, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@go-aegian
Copy link

I followed all steps to migrate and I'm also using knit

npx @connectrpc/connect-migrate@latest

Scanning... ✓
    1 package.json file
    0 lock files
    0 source files
    1 buf.gen.yaml file
It looks like you are already up to date 

But I'm getting these errors when generating protos

npx buf generate

Failure: decode buf.gen.yaml: invalid as version v2: could not unmarshal as YAML: yaml: unmarshal errors:
  line 4: field name not found in type bufconfig.externalGeneratePluginConfigV2
  line 7: field name not found in type bufconfig.externalGeneratePluginConfigV2
  line 10: field name not found in type bufconfig.externalGeneratePluginConfigV2
  line 16: field name not found in type bufconfig.externalGeneratePluginConfigV2

buf.gen.yaml

version: v2
clean: true
plugins:
  - name: go
    out: ../pb
    opt: paths=source_relative
  - name: connect-go
    out: ../pb
    opt: paths=source_relative
  - name: es
    out: ../pb/web
    opt:
      - target=ts
  - name: knit-ts
    out: ../pb/web
    opt:
      - target=ts

buf.yaml

version : v2
lint    :
  use   :
    - DEFAULT
  except:
    - PACKAGE_DIRECTORY_MATCH
    # Relations re-use request and response message names for conciseness.
    - RPC_REQUEST_RESPONSE_UNIQUE
    - RPC_REQUEST_STANDARD_NAME
    - RPC_RESPONSE_STANDARD_NAME
breaking:
  use:
    - FILE

Anybody can provide me with help?

@go-aegian go-aegian added the bug Something isn't working label Nov 21, 2024
@smaye81
Copy link
Member

smaye81 commented Nov 21, 2024

Looks like you are using a v2 buf.gen.yaml file with v1 naming conventions. The property name is no longer valid with v2.

If you are using local plugins, change name to local and it should fix the issue. More details here.

Also just out of curiosity, was this working prior to running the migration tool? The migration tool makes changes to your plugins, but it should not change your version from v1 to v2.

@go-aegian
Copy link
Author

my bad the property name I did not change it, yes migration tool did not change v1 to v2 that was me doing it manually.

now after updating buf to version 1.47.2 and trying to generate again I get this errors, don't know where to get connect-go and knit-ts since it was long ago I had all this running prior to upgrading, could you please help me on this?

Failure: plugin es: exec: "es": executable file not found in %PATH%
plugin go: context canceled
exit status 1
exit status 1
exit status 1
exit status 1
exit status 1
exit status 1
exit status 1
exit status 1
plugin knit-ts: exec: "knit-ts": executable file not found in %PATH%
plugin connect-go: exec: "connect-go": executable file not found in %PATH%

@timostamm
Copy link
Member

With buf.gen.yaml v2, you need to specify local: protoc-gen-es.

I suggest to revert, and run buf config migrate. It'll automatically migrate buf.gen.yaml to v2 and make the necessary changes.

Or keep buf.gen.yaml at v1 - you don't need to upgrade the config file, and can do that separately.

@smaye81
Copy link
Member

smaye81 commented Nov 21, 2024

If you want to use local for the plugins, you'll have to install those locally using the ecosystem for each (if not installed already). So for example:

  • To install protoc-gen-connet-go, you use go install as specified here
  • To install protoc-gen-knit-ts, you use npm install as specified here

As an alternative though, you can just use the remote plugins found on the BSR and you don't have to install anything locally. To do so, change local to remote and change the values to the path on the BSR. You can find the configuration options for Connect-Go here and for Knit here.

@go-aegian
Copy link
Author

Thank you so much for your help. All has been generated successfully.

@go-aegian
Copy link
Author

Just reopened as I was trying to use the plugins locally and when installing following the documentation on the links you provided me with I get these errors. Any light on them of what I'm doing wrong?

proto-gen-knit-ts@0.0.7

npm error While resolving: @bufbuild/protoc-gen-knit-ts@0.0.7
npm error Found: @bufbuild/protobuf@2.2.2
npm error node_modules/@bufbuild/protobuf
npm error   @bufbuild/protobuf@"^2.2.2" from @bufbuild/protoc-gen-es@2.2.2
npm error   node_modules/@bufbuild/protoc-gen-es
npm error     dev @bufbuild/protoc-gen-es@"2.2.2" from the root project
npm error   @bufbuild/protobuf@"2.2.2" from @bufbuild/protoplugin@2.2.2
npm error   node_modules/@bufbuild/protoc-gen-es/node_modules/@bufbuild/protoplugin
npm error     @bufbuild/protoplugin@"2.2.2" from @bufbuild/protoc-gen-es@2.2.2
npm error     node_modules/@bufbuild/protoc-gen-es
npm error       dev @bufbuild/protoc-gen-es@"2.2.2" from the root project
npm error   3 more (@connectrpc/connect, @connectrpc/connect-web, the root project)
npm error
npm error Could not resolve dependency:
npm error peerOptional @bufbuild/protobuf@"^1.5.0" from @bufbuild/protoc-gen-knit-ts@0.0.7
npm error node_modules/@bufbuild/protoc-gen-knit-ts
npm error   dev @bufbuild/protoc-gen-knit-ts@"0.0.7" from the root project
npm error
npm error Conflicting peer dependency: @bufbuild/protobuf@1.10.0
npm error node_modules/@bufbuild/protobuf
npm error   peerOptional @bufbuild/protobuf@"^1.5.0" from @bufbuild/protoc-gen-knit-ts@0.0.7
npm error   node_modules/@bufbuild/protoc-gen-knit-ts
npm error     dev @bufbuild/protoc-gen-knit-ts@"0.0.7" from the root project

package.json has


"devDependencies": {
    "@bufbuild/buf": "1.47.2",
    "@bufbuild/protoc-gen-es": "2.2.2",
    "@bufbuild/protoc-gen-knit-ts": "0.0.7"    
  },
  "dependencies": {
    "@bufbuild/protobuf": "2.2.2",
    "@connectrpc/connect": "2.0.0",
    "@connectrpc/connect-web": "2.0.0"
  } 

buf.gen.yaml (local)

Failure: plugin es: exec: "es": executable file not found in %PATH%
plugin knit-ts: exec: "knit-ts": executable file not found in %PATH%
plugin protoc-gen-go: context canceled
exit status 1
context canceled
exit status 1
exit status 1
exit status 1
exit status 1
exit status 1
context canceled
plugin protoc-gen-connect-go: context canceled
exit status 1
exit status 1
context canceled
exit status 1
exit status 1
exit status 1
exit status 1
context canceled

@go-aegian go-aegian reopened this Nov 21, 2024
@srikrsna-buf
Copy link
Member

Hey! Are you trying to use both knit and connect?

@chrispine
Copy link
Contributor

I'm going to close this, but feel free to reopen if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants