{"record":{"id":"5d627b37b651a5d9","repo":"crowdsecurity/crowdsec","slug":"unable-to-create-folder-s-w","errorCode":null,"errorMessage":"unable to create folder '%s': %w","messagePattern":"unable to create folder '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/appsecrule.go","lineNumber":61,"sourceCode":"\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (t *HubTestItem) installAppsecRuleCustomFrom(appsecrule string, customPath string) (bool, error) {\n\t// we check if its a custom appsec-rule\n\tcustomAppsecRulePath := filepath.Join(customPath, appsecrule)\n\tif _, err := os.Stat(customAppsecRulePath); os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\n\tcustomAppsecRulePathSplit := strings.Split(customAppsecRulePath, \"/\")\n\tcustomAppsecRuleName := customAppsecRulePathSplit[len(customAppsecRulePathSplit)-1]\n\n\titemTypeDirDest := fmt.Sprintf(\"%s/appsec-rules/\", t.RuntimePath)\n\tif err := os.MkdirAll(itemTypeDirDest, os.ModePerm); err != nil {\n\t\treturn false, fmt.Errorf(\"unable to create folder '%s': %w\", itemTypeDirDest, err)\n\t}\n\n\tcustomAppsecRuleDest := fmt.Sprintf(\"%s/appsec-rules/%s\", t.RuntimePath, customAppsecRuleName)\n\tif err := Copy(customAppsecRulePath, customAppsecRuleDest); err != nil {\n\t\treturn false, fmt.Errorf(\"unable to copy appsec-rule from '%s' to '%s': %w\", customAppsecRulePath, customAppsecRuleDest, err)\n\t}\n\n\treturn true, nil\n}\n\nfunc (t *HubTestItem) installAppsecRuleCustom(appsecrule string) error {\n\tfor _, customPath := range t.CustomItemsLocation {\n\t\tfound, err := t.installAppsecRuleCustomFrom(appsecrule, customPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif found {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/appsecrule.go#L43-L79","documentation":"installAppsecRuleCustomFrom creates the runtime appsec-rules directory (os.MkdirAll) before copying a custom rule, and wraps MkdirAll failures. It means the directory <RuntimePath>/appsec-rules/ could not be created — a filesystem-level permission or path problem, not a missing rule.","triggerScenarios":"installAppsecRuleCustom → installAppsecRuleCustomFrom when the custom rule file exists under one of CustomItemsLocation but os.MkdirAll(\"<RuntimePath>/appsec-rules/\", os.ModePerm) returns an error (EACCES, ENOENT ancestor with restricted rights, read-only fs, path component is a file).","commonSituations":"RuntimePath points inside a root-owned tree while tests run unprivileged; a file named 'appsec-rules' already exists at that path; tests executed on a read-only CI workspace.","solutions":["Check ownership/permissions of RuntimePath and create the appsec-rules directory with adequate rights (sudo/chown)","Ensure no regular file named 'appsec-rules' is shadowing the directory path","Point RuntimePath at a writable location for the test run"],"exampleFix":"# before\nmkdir: cannot create directory '/etc/crowdsec/appsec-rules/': Permission denied\n# after\nsudo mkdir -p /etc/crowdsec/appsec-rules && sudo chown -R $USER /etc/crowdsec/appsec-rules","handlingStrategy":"validation","validationCode":"dest := filepath.Join(t.RuntimePath, \"appsec-rules\")\nif fi, err := os.Stat(dest); err == nil && !fi.IsDir() {\n\treturn fmt.Errorf(\"%s exists but is not a directory\", dest)\n}\nif err := os.MkdirAll(dest, 0o755); err != nil {\n\treturn fmt.Errorf(\"cannot create %s: %w\", dest, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run hub tests with write access to RuntimePath (same user as directory owner)","Never place a regular file named 'appsec-rules' under RuntimePath","On CI, ensure the workspace is not mounted read-only during test setup"],"tags":["filesystem","permissions","mkdir"],"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"}