crowdsecurity/crowdsec · error
while enabling %s: %w
Error message
while enabling %s: %w
What it means
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.
Source
Thrown at pkg/hubops/enable.go:91
}
i.State.LocalPath = dest
return nil
}
func (c *EnableCommand) Run(_ context.Context, plan *ActionPlan) error {
i := c.Item
fmt.Fprintln(os.Stdout, "enabling " + colorizeItemName(i.FQName()))
if !i.State.IsDownloaded() {
// XXX: this a warning?
return fmt.Errorf("can't enable %s: not downloaded", i.FQName())
}
if err := CreateInstallLink(i); err != nil {
return fmt.Errorf("while enabling %s: %w", i.FQName(), err)
}
plan.ReloadNeeded = true
i.State.Tainted = false
return nil
}
func (*EnableCommand) OperationType() string {
return "enable"
}
func (c *EnableCommand) ItemType() string {
return c.Item.Type
}
func (c *EnableCommand) Detail() string {View on GitHub (pinned to 909b515798)
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.
Example fix
// before cscli collections enable crowdsecurity/linux # fails on symlink: permission denied // after sudo chown -R crowdsec:crowdsec /etc/crowdsec/collections cscli collections enable crowdsecurity/linux
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat(item.State.DownloadPath); err != nil {
return fmt.Errorf("item %s not downloaded", item.FQName())
}
if err := unix.Access(filepath.Dir(item.State.LocalPath), unix.W_OK); err != nil {
return fmt.Errorf("install dir not writable: %w", err)
} Try / catch
if err := enable(i); err != nil {
var perr *fs.PathError
if errors.As(err, &perr) {
log.Fatalf("enable failed on %s: op=%s path=%s: %v", i.FQName(), perr.Op, perr.Path, perr.Err)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- while creating %s: %w
- while getting data: %w
- %s: %w
- while downloading data for %s: %w
- while creating %s: %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/4d50e64319610a87.
Report an issue: GitHub.