{"record":{"id":"868fbd60d01f6938","repo":"crowdsecurity/crowdsec","slug":"unable-to-create-directory-s-w","errorCode":null,"errorMessage":"unable to create directory '%s': %w","messagePattern":"unable to create directory '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/hubtest_item.go","lineNumber":453,"sourceCode":"\n\t\t\terr = t.ImprovedLogDisplay(crowdsecLogFile)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"unable to read crowdsec log file '%s': %s\", crowdsecLogFile, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := crowdsecDaemon.Process.Kill(); err != nil {\n\t\treturn fmt.Errorf(\"terminating crowdsec daemon: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc createDirs(dirs []string) error {\n\tfor _, dir := range dirs {\n\t\tif err := os.MkdirAll(dir, os.ModePerm); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create directory '%s': %w\", dir, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (t *HubTestItem) RunWithLogFile(ctx context.Context) error {\n\ttestPath := filepath.Join(t.HubTestPath, t.Name)\n\tif _, err := os.Stat(testPath); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"test '%s' doesn't exist in '%s', exiting\", t.Name, t.HubTestPath)\n\t}\n\n\tlogFile := filepath.Join(testPath, t.Config.LogFile)\n\tlogType := t.Config.LogType\n\tdsn := \"file://\" + logFile\n\n\tlogFileStat, err := os.Stat(logFile)\n\tif err != nil {","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/hubtest_item.go#L435-L471","documentation":"createDirs ensures all configured test directories exist via os.MkdirAll; if creation fails the path and cause are wrapped in this error. It is called when installing parsers, scenarios, postoverflows, appsec rules, and by Run, so it usually fails during test-environment setup.","triggerScenarios":"os.MkdirAll(dir) fails for any configured dir: parent path not writable, path exists as a file, or disk/permission problems.","commonSituations":"Running tests as a user without write access to the runtime/hub test directories; a previous run left a file where a directory is expected; read-only container filesystem; TESTDIR/DATADIR pointing into a protected location.","solutions":["Check permissions on the parent of the reported directory (ls -ld) and chown/chmod or run as the right user","Remove any regular file that exists at the reported path so the directory can be created","Point the test runtime dirs (TESTDIR/DATADIR) at a writable location","Clean stale test state from a previous run (make clean / rm -rf test runtime dirs)"],"exampleFix":"// before\nos.MkdirAll(dir, os.ModePerm) // fails if parent unwritable\n// after\n// run harness with writable dirs:\nTESTDIR=/tmp/crowdsec-hubtest ./tests/run.sh","handlingStrategy":"validation","validationCode":"for _, dir := range dirs {\n\tif parent := filepath.Dir(dir); _, err := os.Stat(parent); err != nil {\n\t\treturn fmt.Errorf(\"parent %s not accessible: %w\", parent, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run tests as a user with write access to TESTDIR/DATADIR","Ensure the paths are directories, not files, from prior runs","Use writable temp locations in containers"],"tags":["filesystem","mkdir","permissions","test-harness"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}