slimtoolkit/slim · error

file path is not absolute

Error message

file path is not absolute

What it means

ErrFilePathNotAbs is a sentinel error returned by sodeps.AllExeDependencies and AllDependencies when the given file path is not an absolute path (no leading '/'). The shared-library dependency inspector needs a concrete in-image path to run ldd against.

Source

Thrown at pkg/app/sensor/inspector/sodeps/sodeps.go:18

package sodeps

import (
	"bytes"
	"errors"
	"os"
	"os/exec"
	"path/filepath"
	"strings"

	"github.com/slimtoolkit/slim/pkg/app/sensor/detector/binfile"

	log "github.com/sirupsen/logrus"
)

// Inspector errors
var (
	ErrFilePathNotAbs      = errors.New("file path is not absolute")
	ErrFileNotBin          = errors.New("file is not a binary")
	ErrDepResolverNotFound = errors.New("dependency resolver not found")
)

const (
	resolverExeName = "ldd"
)

func AllExeDependencies(exeFileName string, find bool) ([]string, error) {
	if !strings.HasPrefix(exeFileName, "/") {
		if !find {
			return nil, ErrFilePathNotAbs
		}

		exePath, err := exec.LookPath(exeFileName)
		if err != nil {
			return nil, err
		}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Pass an absolute path (e.g., /usr/local/bin/app) to AllDependencies
  2. For AllExeDependencies, pass find=true so the executable is resolved via exec.LookPath, or absolutize the path yourself
  3. Join relative inputs with the container's working directory before calling

Example fix

// before
deps, err := sodeps.AllDependencies("bin/app")
// after
deps, err := sodeps.AllDependencies("/usr/local/bin/app")
Defensive patterns

Strategy: validation

Validate before calling

// Go: check absolute path before calling
if !filepath.IsAbs(binPath) {
    return fmt.Errorf("path must be absolute: %s", binPath)
}
deps, err := sodeps.AllDependencies(binPath)

Prevention

When it happens

Trigger: Calling AllDependencies with a relative path like 'bin/app'; calling AllExeDependencies with a relative name and find=false (so no PATH lookup is performed).

Common situations: Passing a path from relative Dockerfile WORKDIR context; passing a bare executable name while expecting implicit PATH resolution without enabling the find option.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/f265bb3744af27cf. Report an issue: GitHub.