crowdsecurity/crowdsec · error

path to hub '%s' doesn't exist, can't run

Error message

path to hub '%s' doesn't exist, can't run

What it means

After creating the data dir, NewHubTest stats hubPath and returns "path to hub '%s' doesn't exist, can't run" if os.Stat reports IsNotExist. hubtest cannot operate without a hub checkout, so it aborts early.

Source

Thrown at pkg/hubtest/hubtest.go:116

	}

	return resolved, nil
}

func NewHubTest(hubPath string, crowdsecPath string, cscliPath string, isAppsecTest bool) (HubTest, error) {
	hubPath, err := filepath.Abs(hubPath)
	if err != nil {
		return HubTest{}, fmt.Errorf("can't get absolute path of hub: %w", err)
	}

	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,

View on GitHub (pinned to 909b515798)

Solutions

  1. Verify the hub path exists (ls <hubPath>) and fix the path passed to hubtest
  2. Clone/update the hub first (cscli hub update or the test env bootstrap script) before running hubtest
  3. Pass an absolute path to the hub checkout to avoid relative-path resolution mistakes
  4. Check CI cache restore steps actually populated the hub directory

Example fix

// before
hubtest run --hub ./hubb   # typo
// after
hubtest run --hub /path/to/crowdsec-hub   # existing checkout
Defensive patterns

Strategy: validation

Validate before calling

if info, err := os.Stat(hubPath); err != nil {
    return fmt.Errorf("hub path %s missing: %w", hubPath, err)
} else if !info.IsDir() {
    return fmt.Errorf("hub path %s is not a directory", hubPath)
}

Try / catch

ht, err := hubtest.NewHubTest(hubPath, ...)
if err != nil {
    if strings.Contains(err.Error(), "doesn't exist") { /* clone/update the hub, then retry */ }
}

Prevention

When it happens

Trigger: Calling NewHubTest with a hubPath that does not exist on disk — typo in the path, hub not yet cloned/hydrated, or hub removed by a prior cleanup step.

Common situations: Running hubtest before running the hub update/clone step; wrong working directory so the relative hub path doesn't resolve; CI cache missing the hub directory; typo like ./hub vs ./crowdsec-hub.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/3c8cd2ae04da2ece. Report an issue: GitHub.