{"record":{"id":"3c8cd2ae04da2ece","repo":"crowdsecurity/crowdsec","slug":"path-to-hub-s-doesn-t-exist-can-t-run","errorCode":null,"errorMessage":"path to hub '%s' doesn't exist, can't run","messagePattern":"path to hub '(.+?)' doesn't exist, can't run","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/hubtest.go","lineNumber":116,"sourceCode":"\t}\n\n\treturn resolved, nil\n}\n\nfunc NewHubTest(hubPath string, crowdsecPath string, cscliPath string, isAppsecTest bool) (HubTest, error) {\n\thubPath, err := filepath.Abs(hubPath)\n\tif err != nil {\n\t\treturn HubTest{}, fmt.Errorf(\"can't get absolute path of hub: %w\", err)\n\t}\n\n\tsharedDataDir := filepath.Join(hubPath, \".cache\", \"data\")\n\tif err = os.MkdirAll(sharedDataDir, 0o700); err != nil {\n\t\treturn HubTest{}, fmt.Errorf(\"while creating data dir: %w\", err)\n\t}\n\n\t// we can't use hubtest without the hub\n\tif _, err = os.Stat(hubPath); os.IsNotExist(err) {\n\t\treturn HubTest{}, fmt.Errorf(\"path to hub '%s' doesn't exist, can't run\", hubPath)\n\t}\n\t// we can't use hubtest without crowdsec binary\n\tif crowdsecPath, err = resolveBinaryPath(crowdsecPath); err != nil {\n\t\treturn HubTest{}, fmt.Errorf(\"can't find crowdsec binary: %w\", err)\n\t}\n\n\t// we can't use hubtest without cscli binary\n\tif cscliPath, err = resolveBinaryPath(cscliPath); err != nil {\n\t\treturn HubTest{}, fmt.Errorf(\"can't find cscli binary: %w\", err)\n\t}\n\n\tif isAppsecTest {\n\t\tHubTestPath := filepath.Join(hubPath, \".appsec-tests\")\n\t\thubIndexFile := filepath.Join(hubPath, \".index.json\")\n\n\t\tlocal := &csconfig.LocalHubCfg{\n\t\t\tHubDir:         hubPath,\n\t\t\tHubIndexFile:   hubIndexFile,","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/hubtest.go#L98-L134","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the hub path exists (ls <hubPath>) and fix the path passed to hubtest","Clone/update the hub first (cscli hub update or the test env bootstrap script) before running hubtest","Pass an absolute path to the hub checkout to avoid relative-path resolution mistakes","Check CI cache restore steps actually populated the hub directory"],"exampleFix":"// before\nhubtest run --hub ./hubb   # typo\n// after\nhubtest run --hub /path/to/crowdsec-hub   # existing checkout","handlingStrategy":"validation","validationCode":"if info, err := os.Stat(hubPath); err != nil {\n    return fmt.Errorf(\"hub path %s missing: %w\", hubPath, err)\n} else if !info.IsDir() {\n    return fmt.Errorf(\"hub path %s is not a directory\", hubPath)\n}","typeGuard":null,"tryCatchPattern":"ht, err := hubtest.NewHubTest(hubPath, ...)\nif err != nil {\n    if strings.Contains(err.Error(), \"doesn't exist\") { /* clone/update the hub, then retry */ }\n}","preventionTips":["Always bootstrap/clone the hub before running hubtest","Use absolute paths to avoid cwd-relative mistakes","Verify CI cache restore populated the hub directory","Double-check the --hub flag value for typos"],"tags":["filesystem","path","hubtest","not-found"],"backgroundTag":"file-not-found","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"}