{"record":{"id":"30c7fc756bd752f8","repo":"crowdsecurity/crowdsec","slug":"please-provide-a-data-directory-with-the-data-dir","errorCode":null,"errorMessage":"please provide a data directory with the 'data_dir' directive in the 'config_paths' section","messagePattern":"please provide a data directory with the 'data_dir' directive in the 'config_paths' section","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csconfig/config_paths.go","lineNumber":29,"sourceCode":"\tSimulationFilePath string `yaml:\"simulation_path,omitempty\"`\n\tHubIndexFile       string `yaml:\"index_path,omitempty\"` // path of the .index.json\n\tHubDir             string `yaml:\"hub_dir,omitempty\"`\n\tPluginDir          string `yaml:\"plugin_dir,omitempty\"`\n\tNotificationDir    string `yaml:\"notification_dir,omitempty\"`\n\tPatternDir         string `yaml:\"pattern_dir,omitempty\"`\n}\n\nfunc (c *Config) loadConfigurationPaths() error {\n\tif c.ConfigPaths == nil {\n\t\treturn errors.New(\"no configuration paths provided\")\n\t}\n\n\tif c.ConfigPaths.ConfigDir == \"\" {\n\t\tc.ConfigPaths.ConfigDir = filepath.Dir(c.FilePath)\n\t}\n\n\tif c.ConfigPaths.DataDir == \"\" {\n\t\treturn errors.New(\"please provide a data directory with the 'data_dir' directive in the 'config_paths' section\")\n\t}\n\n\tif c.ConfigPaths.HubDir == \"\" {\n\t\tc.ConfigPaths.HubDir = filepath.Join(c.ConfigPaths.ConfigDir, \"hub\")\n\t}\n\n\tif c.ConfigPaths.HubIndexFile == \"\" {\n\t\tc.ConfigPaths.HubIndexFile = filepath.Join(c.ConfigPaths.HubDir, \".index.json\")\n\t}\n\n\tif c.ConfigPaths.NotificationDir == \"\" {\n\t\tc.ConfigPaths.NotificationDir = filepath.Join(c.ConfigPaths.ConfigDir, \"notifications\")\n\t}\n\n\tif c.ConfigPaths.PatternDir == \"\" {\n\t\tc.ConfigPaths.PatternDir = filepath.Join(c.ConfigPaths.ConfigDir, \"patterns\")\n\t}\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/config_paths.go#L11-L47","documentation":"After defaulting ConfigDir from the config file location, loadConfigurationPaths requires an explicit data_dir. The data directory holds the database and hub artifacts, so it has no safe default and must be declared in the 'config_paths' section. Missing it aborts configuration loading.","triggerScenarios":"A config.yaml whose config_paths section sets config_dir but omits data_dir, passed to NewConfig via -c.","commonSituations":"Partially copied config files; users deleting the data_dir line thinking it is derived from config_dir; packaging a config tree for containers and forgetting data_dir.","solutions":["Add 'data_dir: /var/lib/crowdsec/data' (or your path) under config_paths in the config file","Ensure the data_dir exists and the crowdsec user can write to it","When generating configs programmatically, always set ConfigPaths.DataDir alongside ConfigDir"],"exampleFix":"// before\nconfig_paths:\n  config_dir: /etc/crowdsec\n\n// after\nconfig_paths:\n  config_dir: /etc/crowdsec\n  data_dir: /var/lib/crowdsec/data","handlingStrategy":"validation","validationCode":"if cfg.ConfigPaths != nil && cfg.ConfigPaths.DataDir == \"\" {\n    return fmt.Errorf(\"config_paths.data_dir is required\")\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadDBConfig(false); err != nil {\n    if strings.Contains(err.Error(), \"data directory\") {\n        log.Fatalf(\"set data_dir in config_paths of %s\", cfg.FilePath)\n    }\n    return err\n}","preventionTips":["Never trim the config_paths section when hand-editing config.yaml","In generated/container configs, template all three of config_dir, data_dir, hub_dir","Check that the data_dir path exists and is writable before starting"],"tags":["config","crowdsec","paths"],"backgroundTag":"missing-required-config-field","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"}