caddyserver/caddy · error
at least one package name must be specified
Error message
at least one package name must be specified
What it means
`caddy add-package` refuses to run with zero package arguments. At least one module path is required because the command's whole purpose is to add plugins to the current build.
Source
Thrown at cmd/packagesfuncs.go:70
// accommodate module paths that have @ in them, but we can only tolerate that if there's also
// a version, otherwise we don't know if it's a version separator or part of the file path
lastVersionSplit := strings.LastIndex(arg, versionSplit)
if lastVersionSplit < 0 {
module = arg
} else {
module, version = arg[:lastVersionSplit], arg[lastVersionSplit+1:]
}
if module == "" {
err = fmt.Errorf("module name is required")
}
return module, version, err
}
func cmdAddPackage(fl Flags) (int, error) {
if len(fl.Args()) == 0 {
return caddy.ExitCodeFailedStartup, fmt.Errorf("at least one package name must be specified")
}
_, nonstandard, _, err := getModules()
if err != nil {
return caddy.ExitCodeFailedStartup, fmt.Errorf("unable to enumerate installed plugins: %v", err)
}
pluginPkgs, err := getPluginPackages(nonstandard)
if err != nil {
return caddy.ExitCodeFailedStartup, err
}
for _, arg := range fl.Args() {
module, version, err := splitModule(arg)
if err != nil {
return caddy.ExitCodeFailedStartup, fmt.Errorf("invalid module name: %v", err)
}
// only allow a version to be specified if it's different from the existing version
if _, ok := pluginPkgs[module]; ok && (version == "" || pluginPkgs[module].Version == version) {
return caddy.ExitCodeFailedStartup, fmt.Errorf("package is already added")View on GitHub (pinned to 50e54ee279)
Solutions
- Pass one or more module paths: `caddy add-package github.com/caddy-dns/cloudflare github.com/mholt/caddy-ratelimit`
- In scripts, guard the invocation: `[ -n "$PLUGINS" ] && caddy add-package $PLUGINS`
Example fix
# before caddy add-package # after caddy add-package github.com/caddy-dns/cloudflare
Defensive patterns
Strategy: validation
Validate before calling
[ "$#" -ge 1 ] || { echo 'usage: caddy add-package <module> [...]'; exit 1; }
caddy add-package "$@" Prevention
- Guard scripted invocations against empty package lists
When it happens
Trigger: Running `caddy add-package` with no positional args, or with args consumed by flag parsing so that fl.Args() is empty.
Common situations: Scripts where the package list variable is empty (`caddy add-package $PLUGINS` with PLUGINS unset), or invoking the command expecting it to be interactive.
Related errors
- module name is required
- invalid module name: %v
- download failed: %v
- too many unflagged arguments
- parsing environment file: %v
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/e9142ffe73104d33.
Report an issue: GitHub.