{"record":{"id":"055e48c6eb49e7ae","repo":"caddyserver/caddy","slug":"package-is-already-added","errorCode":null,"errorMessage":"package is already added","messagePattern":"package is already added","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/packagesfuncs.go","lineNumber":88,"sourceCode":"\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"at least one package name must be specified\")\n\t}\n\t_, nonstandard, _, err := getModules()\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"unable to enumerate installed plugins: %v\", err)\n\t}\n\tpluginPkgs, err := getPluginPackages(nonstandard)\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, err\n\t}\n\n\tfor _, arg := range fl.Args() {\n\t\tmodule, version, err := splitModule(arg)\n\t\tif err != nil {\n\t\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"invalid module name: %v\", err)\n\t\t}\n\t\t// only allow a version to be specified if it's different from the existing version\n\t\tif _, ok := pluginPkgs[module]; ok && (version == \"\" || pluginPkgs[module].Version == version) {\n\t\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"package is already added\")\n\t\t}\n\t\tpluginPkgs[module] = pluginPackage{Version: version, Path: module}\n\t}\n\n\treturn upgradeBuild(pluginPkgs, fl)\n}\n\nfunc cmdRemovePackage(fl Flags) (int, error) {\n\tif len(fl.Args()) == 0 {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"at least one package name must be specified\")\n\t}\n\t_, nonstandard, _, err := getModules()\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"unable to enumerate installed plugins: %v\", err)\n\t}\n\tpluginPkgs, err := getPluginPackages(nonstandard)\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, err","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/cmd/packagesfuncs.go#L70-L106","documentation":"`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.","triggerScenarios":"`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.","commonSituations":"Idempotent install scripts that blindly add the same plugins on every run; following a tutorial that adds a plugin you already have.","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"],"exampleFix":"# before\ncaddy add-package github.com/caddy-dns/cloudflare   # already installed at v0.2.1\n\n# after\ncaddy add-package github.com/caddy-dns/cloudflare@v0.2.2\n# or simply\ncaddy upgrade","handlingStrategy":"validation","validationCode":"MOD=github.com/caddy-dns/cloudflare\nif caddy list-modules -v 2>/dev/null | grep -q \"${MOD}@\"; then echo 'already installed; use caddy upgrade or pin a different version'; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make install scripts check `caddy list-modules -v` before adding","Use `caddy upgrade` to refresh versions of existing plugins"],"tags":["caddy","add-package","idempotency","cli","plugins"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}