crowdsecurity/crowdsec · error
can't find cscli binary: %w
Error message
can't find cscli binary: %w
What it means
Identical guard to the crowdsec one, but for the cscli binary: NewHubTest calls resolveBinaryPath(cscliPath) and wraps any failure as 'can't find cscli binary: %w'. Hub test items drive cscli (e.g. `machines add`) against the runtime environment, so a missing cscli makes the test unusable.
Source
Thrown at pkg/hubtest/hubtest.go:125
}
sharedDataDir := filepath.Join(hubPath, ".cache", "data")
if err = os.MkdirAll(sharedDataDir, 0o700); err != nil {
return HubTest{}, fmt.Errorf("while creating data dir: %w", err)
}
// we can't use hubtest without the hub
if _, err = os.Stat(hubPath); os.IsNotExist(err) {
return HubTest{}, fmt.Errorf("path to hub '%s' doesn't exist, can't run", hubPath)
}
// we can't use hubtest without crowdsec binary
if crowdsecPath, err = resolveBinaryPath(crowdsecPath); err != nil {
return HubTest{}, fmt.Errorf("can't find crowdsec binary: %w", err)
}
// we can't use hubtest without cscli binary
if cscliPath, err = resolveBinaryPath(cscliPath); err != nil {
return HubTest{}, fmt.Errorf("can't find cscli binary: %w", err)
}
if isAppsecTest {
HubTestPath := filepath.Join(hubPath, ".appsec-tests")
hubIndexFile := filepath.Join(hubPath, ".index.json")
local := &csconfig.LocalHubCfg{
HubDir: hubPath,
HubIndexFile: hubIndexFile,
InstallDir: HubTestPath,
InstallDataDir: sharedDataDir,
}
hub, err := cwhub.NewHub(local, nil)
if err != nil {
return HubTest{}, err
}
View on GitHub (pinned to 909b515798)
Solutions
- Run `make build` so ./cscli exists alongside crowdsec, then pass its absolute path to NewHubTest.
- Check the path exists and is executable: `ls -l <cscliPath>`; chmod +x if needed.
- Ensure cscli is on $PATH if you rely on name-only resolution (`command -v cscli`).
Example fix
// before ht, err := hubtest.NewHubTest(ctx, hubPath, crowdsecPath, "cscli", false) // after ht, err := hubtest.NewHubTest(ctx, hubPath, crowdsecPath, "/abs/path/to/cscli", false)
Defensive patterns
Strategy: validation
Validate before calling
if _, err := os.Stat(cscliPath); err != nil || func() bool { fi, _ := os.Stat(cscliPath); return fi.Mode()&0o111 == 0 }() {
return fmt.Errorf("cscli missing or not executable: %s", cscliPath)
} Type guard
func cscliReady(p string) bool {
fi, err := os.Stat(p)
return err == nil && !fi.IsDir() && fi.Mode()&0o111 != 0
} Prevention
- Build both binaries together (`make build`) — never crowdsec alone.
- Verify cscli presence in CI setup steps before invoking hub tests.
- Pass absolute paths instead of relying on PATH.
When it happens
Trigger: Calling hubtest.NewHubTest with a cscliPath that is empty with no cscli on PATH, nonexistent, or not executable.
Common situations: Building only the crowdsec binary (e.g. `go build ./cmd/crowdsec`) and forgetting cscli; PATH not including the build output directory; typo'd path after moving the binary between containers in CI.
Related errors
- can't find crowdsec binary: %w
- ErrNucleiRunFail
- %q is a directory, not a file
- log file '%s' is empty, please fill it with log
- error while stats '%s': %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/2c9ec9053995044f.
Report an issue: GitHub.