kratos upgrade command upgrades the Kratos CLI and all related protoc plugins to their latest versions.
Usage
Description
This command installs or updates all Kratos-related tools usinggo install. It ensures you have the latest versions of:
- The Kratos CLI itself
- All protoc plugins required for code generation
- Standard Protocol Buffer and gRPC tools
What Gets Upgraded
The command upgrades the following packages:Kratos CLI
github.com/go-kratos/kratos/cmd/kratos/v2The main Kratos command-line toolprotoc-gen-go-http
github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2Generates Kratos HTTP transport code from proto filesprotoc-gen-go-errors
github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2Generates error definitions and helper functionsprotoc-gen-go
google.golang.org/protobuf/cmd/protoc-gen-goStandard Go protocol buffer compiler pluginprotoc-gen-go-grpc
google.golang.org/grpc/cmd/protoc-gen-go-grpcGenerates Go gRPC service codeprotoc-gen-openapi
github.com/google/gnostic/cmd/protoc-gen-openapiGenerates OpenAPI specifications from proto filesWhen to Use
You should runkratos upgrade when:
Initial Setup
After installing Kratos for the first time to ensure all plugins are installed
New Release
When a new version of Kratos is released with new features or bug fixes
Missing Plugins
If
kratos proto client fails due to missing protoc pluginsCompatibility Issues
When you need to ensure all tools are compatible with each other
Examples
Basic Upgrade
After Fresh Installation
Before Generating Proto Code
How It Works
The command executesgo install for each package with the @latest tag:
Installation Location
All tools are installed to your$GOPATH/bin or $HOME/go/bin directory. Ensure this directory is in your system’s PATH:
Verification
After upgrading, verify the installations:Automatic Upgrade
Thekratos proto client command automatically runs kratos upgrade if it detects missing protoc plugins. You can also run it manually to ensure everything is up to date.
Prerequisites
Troubleshooting
Command not found after upgrade
Command not found after upgrade
Ensure Or restart your terminal after adding it to your shell configuration.
$GOPATH/bin is in your PATH:Permission denied errors
Permission denied errors
If you encounter permission errors, ensure you have write access to
$GOPATH/bin:Network/download failures
Network/download failures
If downloads fail due to network issues:
Version conflicts
Version conflicts
If you need specific versions instead of latest:
Related Commands
kratos proto client- Uses the upgraded protoc plugins- Check version:
kratos --version
It’s recommended to run
kratos upgrade periodically to benefit from the latest features, performance improvements, and bug fixes.