{"record":{"id":"f1d4fdf89d2c40af","repo":"crowdsecurity/crowdsec","slug":"failed-to-get-absolute-path-of-q-w","errorCode":null,"errorMessage":"failed to get absolute path of %q: %w","messagePattern":"failed to get absolute path of %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/csconfig/paths.go","lineNumber":24,"sourceCode":"\n\tlog \"github.com/sirupsen/logrus\"\n)\n\nfunc ensureAbsolutePath(p *string) error {\n\t// TODO: this will become a straight IsAbs check + return error\n\tvar err error\n\n\tif *p == \"\" {\n\t\treturn nil\n\t}\n\n\tif !filepath.IsAbs(*p) {\n\t\tlog.Warnf(\"Using a relative path for %q is deprecated and will be disallowed in a future release\", *p)\n\t}\n\n\t*p, err = filepath.Abs(*p)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get absolute path of %q: %w\", *p, err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":6,"sourceCodeEnd":29,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/paths.go#L6-L29","documentation":"ensureAbsolutePath normalizes configured paths to absolute ones via filepath.Abs before crowdsec uses them. filepath.Abs essentially only fails when it cannot determine the current working directory (e.g. the cwd was deleted, or os.Getwd hits an OS error). The wrapper preserves the original path and the underlying error so the operator can tell which config path is problematic.","triggerScenarios":"A relative path is configured (apparent from the deprecation warning) and the process's current working directory cannot be resolved — classically when the binary is started from a directory that has been deleted, or cwd resolution fails at OS level.","commonSituations":"Running crowdsec from a tmpfs/removed directory, systemd units with a WorkingDirectory that no longer exists, or container setups where the workdir was unmounted before exec.","solutions":["Restart crowdsec from a valid, existing working directory (e.g. cd / before launching).","Fix the unit/container working directory: set WorkingDirectory=/etc/crowdsec in the systemd unit or workdir in the container spec.","Replace relative config paths with absolute ones in the yaml (this also silences the deprecation warning) so cwd resolution no longer matters.","Check `pwd` works in the launching shell; if the directory was removed, open a new shell."],"exampleFix":"// before (config.yaml)\nconfig_paths:\n  config_dir: ./config\n// after\nconfig_paths:\n  config_dir: /etc/crowdsec/config","handlingStrategy":"validation","validationCode":"if !filepath.IsAbs(p) {\n    abs, err := filepath.Abs(p)\n    if err != nil {\n        return fmt.Errorf(\"cannot resolve %q: %w (check working directory)\", p, err)\n    }\n    p = abs\n}\nif _, err := os.Stat(p); err != nil {\n    return fmt.Errorf(\"path %q missing: %w\", p, err)\n}","typeGuard":null,"tryCatchPattern":"if err := csconfig.LoadCrowdsec(...); err != nil {\n    if strings.Contains(err.Error(), \"failed to get absolute path\") {\n        // cwd is invalid; restart from a valid directory or fix paths to absolute\n    }\n}","preventionTips":["Always use absolute paths in crowdsec config files — relative ones are deprecated anyway.","Ensure systemd units define a valid WorkingDirectory that exists.","In containers, mount config paths at stable absolute locations."],"tags":["paths","filesystem","config"],"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"}