crowdsecurity/crowdsec · error
can't get absolute path of '%s': %w
Error message
can't get absolute path of '%s': %w
What it means
installScenarioItem resolves the absolute path of a hub scenario by joining the hub root with the item's RemotePath. filepath.Abs only fails when the current working directory cannot be determined (or in rare syscall errors). The error wraps that failure while naming the path being resolved.
Source
Thrown at pkg/hubtest/scenario.go:14
package hubtest
import (
"fmt"
"os"
"path/filepath"
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
)
func (t *HubTestItem) installScenarioItem(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/scenarios/crowdsecurity/
hubDirScenarioDest := filepath.Join(t.RuntimeHubPath, filepath.Dir(item.RemotePath))
// runtime/parsers/scenarios/
itemTypeDirDest := fmt.Sprintf("%s/scenarios/", t.RuntimePath)
if err := createDirs([]string{hubDirScenarioDest, itemTypeDirDest}); err != nil {
return err
}
// runtime/hub/scenarios/crowdsecurity/ssh-bf.yaml
hubDirScenarioPath := filepath.Join(hubDirScenarioDest, sourceFilename)
if err := Copy(sourcePath, hubDirScenarioPath); err != nil {
return fmt.Errorf("unable to copy '%s' to '%s': %w", sourcePath, hubDirScenarioPath, err)View on GitHub (pinned to 909b515798)
Solutions
- Run the process from an existing, accessible working directory.
- In containers/scripts, ensure the cwd is not deleted before the test runs (cd to a valid dir first).
- Inspect the wrapped error (%w) to confirm it is syscall.ENOENT on the cwd.
Example fix
// before cd /tmp/workdir && rm -rf /tmp/workdir && ./crowdsec test run ... // after cd /tmp && ./crowdsec test run ...
Defensive patterns
Strategy: try-catch
Validate before calling
if wd, err := os.Getwd(); err != nil || wd == "" {
// resolve paths relative to an explicit root instead of relying on cwd
} Try / catch
if _, err := os.Getwd(); err != nil {
return fmt.Errorf("working directory unavailable: %w", err)
} Prevention
- Never delete the process's own working directory in scripts/CI.
- Pass absolute hub paths so filepath.Abs is trivially safe.
When it happens
Trigger: Calling installScenario -> installScenarioItem when the OS cannot determine the process working directory (deleted cwd), so filepath.Abs returns an error.
Common situations: Running crowdsec/ci tests from a directory that has been removed or replaced (common in containers or when the test harness deletes its own cwd); very unusual on healthy systems.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- couldn't find custom postoverflow '%s' in the following loca
- unable to copy '%s' to '%s': %w
- unable to symlink scenario '%s' to '%s': %w
- unable to create folder '%s': %w
- unable to copy scenario from '%s' to '%s': %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/0fc982a618cda349.
Report an issue: GitHub.