{"record":{"id":"4d50e64319610a87","repo":"crowdsecurity/crowdsec","slug":"while-enabling-s-w","errorCode":null,"errorMessage":"while enabling %s: %w","messagePattern":"while enabling (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubops/enable.go","lineNumber":91,"sourceCode":"\t}\n\n\ti.State.LocalPath = dest\n\n\treturn nil\n}\n\nfunc (c *EnableCommand) Run(_ context.Context, plan *ActionPlan) error {\n\ti := c.Item\n\n\tfmt.Fprintln(os.Stdout, \"enabling \" + colorizeItemName(i.FQName()))\n\n\tif !i.State.IsDownloaded() {\n\t\t// XXX: this a warning?\n\t\treturn fmt.Errorf(\"can't enable %s: not downloaded\", i.FQName())\n\t}\n\n\tif err := CreateInstallLink(i); err != nil {\n\t\treturn fmt.Errorf(\"while enabling %s: %w\", i.FQName(), err)\n\t}\n\n\tplan.ReloadNeeded = true\n\n\ti.State.Tainted = false\n\n\treturn nil\n}\n\nfunc (*EnableCommand) OperationType() string {\n\treturn \"enable\"\n}\n\nfunc (c *EnableCommand) ItemType() string {\n\treturn c.Item.Type\n}\n\nfunc (c *EnableCommand) Detail() string {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubops/enable.go#L73-L109","documentation":"Creating the installation symlink (CreateInstallLink) for an already-downloaded hub item failed during the enable step of a hubops action plan. The wrapper identifies which item (FQName) failed to enable; the inner error carries the symlink/permission cause.","triggerScenarios":"During `cscli <type> enable <item>` when CreateInstallLink fails with any of its underlying errors: MkdirAll denied (1095), Lstat anomaly (1096), or os.Symlink failure (1097) — e.g. missing DownloadPath or unwritable install directory.","commonSituations":"Non-root execution against root-owned /etc/crowdsec; item downloaded but its file later removed; leftover conflicting file at the link destination; container images with /etc mounted read-only.","solutions":["Read the wrapped inner error (mkdir/lstat/symlink) and apply the matching fix.","Check that i.State.DownloadPath exists and the install directory is writable by the running user.","Re-run the command with sudo/root if the install directory is root-owned.","If state is inconsistent, `cscli hub update` and reinstall the item, then enable again."],"exampleFix":"// before\ncscli collections enable crowdsecurity/linux   # fails on symlink: permission denied\n// after\nsudo chown -R crowdsec:crowdsec /etc/crowdsec/collections\ncscli collections enable crowdsecurity/linux","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(item.State.DownloadPath); err != nil {\n    return fmt.Errorf(\"item %s not downloaded\", item.FQName())\n}\nif err := unix.Access(filepath.Dir(item.State.LocalPath), unix.W_OK); err != nil {\n    return fmt.Errorf(\"install dir not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := enable(i); err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        log.Fatalf(\"enable failed on %s: op=%s path=%s: %v\", i.FQName(), perr.Op, perr.Path, perr.Err)\n    }\n    return err\n}","preventionTips":["Ensure the crowdsec user can write the target install directory before enabling items.","Fix the underlying mkdir/lstat/symlink error (wrapped in the message) first.","Reinstall the item if hub state is inconsistent after manual intervention.","Run cscli with the same identity (user/sudo) as the crowdsec service to avoid permission drift."],"tags":["hub","enable","wrapped-error","permissions"],"backgroundTag":"file-write-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}