crowdsecurity/crowdsec · error
can't get absolute path of '%s': %w
Error message
can't get absolute path of '%s': %w
What it means
installAppsecRuleItem fails while resolving the hub item's absolute source path (filepath.Abs on HubPath + item.RemotePath). filepath.Abs only fails on malformed relative paths (e.g. unrecoverable working-directory errors), so this almost always indicates a broken hub index or hub path state.
Source
Thrown at pkg/hubtest/appsecrule.go:17
package hubtest
import (
"fmt"
"os"
"path/filepath"
"strings"
log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
)
func (t *HubTestItem) installAppsecRuleItem(item *cwhub.Item) error {
sourcePath, err := filepath.Abs(filepath.Join(t.HubPath, item.RemotePath))
if err != nil {
return fmt.Errorf("can't get absolute path of '%s': %w", sourcePath, err)
}
sourceFilename := filepath.Base(sourcePath)
// runtime/hub/appsec-rules/author/appsec-rule
hubDirAppsecRuleDest := filepath.Join(t.RuntimeHubPath, filepath.Dir(item.RemotePath))
// runtime/appsec-rules/
itemTypeDirDest := fmt.Sprintf("%s/appsec-rules/", t.RuntimePath)
if err := createDirs([]string{hubDirAppsecRuleDest, itemTypeDirDest}); err != nil {
return err
}
// runtime/hub/appsec-rules/crowdsecurity/rule.yaml
hubDirAppsecRulePath := filepath.Join(itemTypeDirDest, sourceFilename)
if err := Copy(sourcePath, hubDirAppsecRulePath); err != nil {
return fmt.Errorf("unable to copy '%s' to '%s': %w", sourcePath, hubDirAppsecRulePath, err)View on GitHub (pinned to 909b515798)
Solutions
- Run 'cscli hub update' to rebuild a clean hub index, then retry the test installation
- Verify t.HubPath is a valid absolute path and the appsec-rule exists at HubPath/RemotePath
- Ensure the process working directory exists and is accessible (filepath.Abs needs it for relative paths)
Example fix
// before
hub := &HubTestItem{HubPath: ""}
hub.installAppsecRule("crowdsecurity/vpatch-priv-esc")
// after
hub := &HubTestItem{HubPath: "/etc/crowdsec/hub"}
hub.installAppsecRule("crowdsecurity/vpatch-priv-esc") Defensive patterns
Strategy: validation
Validate before calling
abs, err := filepath.Abs(filepath.Join(hubPath, item.RemotePath))
if err != nil {
log.Fatalf("bad hub path for %s: %v", item.Name, err)
}
if _, err := os.Stat(abs); err != nil {
log.Fatalf("missing rule file %s: run 'cscli hub update'", abs)
} Try / catch
if err := t.installAppsecRule(name); err != nil {
if strings.Contains(err.Error(), "can't get absolute path") {
// refresh hub index and retry once
}
return err
} Prevention
- Keep the hub index fresh ('cscli hub update') before running hub tests
- Verify HubPath is absolute and points to a real checkout
- Avoid deleting or renaming the process working directory while tests run
When it happens
Trigger: Calling installAppsecRule with a name that resolves to a hub item whose RemotePath joined with t.HubPath cannot be made absolute — realistically only when filepath.Abs gets an error from the working directory lookup or the joined path is pathological.
Common situations: Corrupt hub index entry with an empty/invalid RemotePath; running with a deleted or inaccessible current working directory (filepath.Abs relies on it for relative paths); HubPath misconfigured to an odd relative value.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- no appsec_config provided
- plugins are enabled, but config_paths.plugin_dir is not defi
- please provide a data directory with the 'data_dir' directiv
- no hub configuration provided
- too many levels of symbolic links
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/e59ba0bfbbd6276d.
Report an issue: GitHub.