caddyserver/caddy · warning
package is already added
Error message
package is already added
What it means
`caddy add-package` refuses to re-add a module that is already part of the current build with the same (or unspecified) version. A version pin is only accepted if it DIFFERS from the installed version — that is the upgrade/downgrade path. This guard prevents pointless rebuild downloads.
Source
Thrown at cmd/packagesfuncs.go:88
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")
}
pluginPkgs[module] = pluginPackage{Version: version, Path: module}
}
return upgradeBuild(pluginPkgs, fl)
}
func cmdRemovePackage(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, errView on GitHub (pinned to 50e54ee279)
Solutions
- If you meant to change the version, pin one different from the installed: `caddy add-package github.com/caddy-dns/cloudflare@v0.2.2`
- If you want the latest version, use `caddy upgrade` instead — it refreshes all existing plugins
- In idempotent scripts, first check `caddy list-modules -v --packages` and skip already-present modules
Example fix
# before caddy add-package github.com/caddy-dns/cloudflare # already installed at v0.2.1 # after caddy add-package github.com/caddy-dns/cloudflare@v0.2.2 # or simply caddy upgrade
Defensive patterns
Strategy: validation
Validate before calling
MOD=github.com/caddy-dns/cloudflare
if caddy list-modules -v 2>/dev/null | grep -q "${MOD}@"; then echo 'already installed; use caddy upgrade or pin a different version'; fi Prevention
- Make install scripts check `caddy list-modules -v` before adding
- Use `caddy upgrade` to refresh versions of existing plugins
When it happens
Trigger: `caddy add-package github.com/caddy-dns/cloudflare` when that plugin is already compiled in; or specifying the exact version currently installed. Specifying a DIFFERENT version is allowed and proceeds.
Common situations: Idempotent install scripts that blindly add the same plugins on every run; following a tutorial that adds a plugin you already have.
Related errors
- unable to enumerate installed plugins: %v
- invalid module name: %v
- package is not added
- encoding new config: %v
- directive '%s' is not an ordered HTTP handler, so it cannot
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/055e48c6eb49e7ae.
Report an issue: GitHub.