slimtoolkit/slim · error

file is not a binary

Error message

file is not a binary

What it means

ErrFileNotBin is returned by sodeps.AllDependencies when the binfile.Detected check indicates the target file is not a binary (executable or shared object). ldd-based dependency resolution only makes sense on ELF binaries, so the inspector rejects anything else up front.

Solutions

  1. Point the API at the actual ELF executable or .so file (e.g., /usr/bin/python3 rather than the script)
  2. Verify the file with 'file <path>' — it should report ELF executable or shared object
  3. If the binary is packed or unrecognized, check binfile.Detected behavior or inspect dependencies differently
  4. Fix app_name/app_entrypoint config so it targets the real binary, not a wrapper script

Example fix

// before
deps, err := sodeps.AllDependencies("/app/run.sh")
// after
deps, err := sodeps.AllDependencies("/bin/sh") // or the real ELF binary that runs your app
Defensive patterns

Strategy: validation

Validate before calling

// Go: check the file is an ELF binary before dependency inspection
props, err := binfile.Detected(binPath)
if err != nil || props == nil || !props.IsBin {
    return fmt.Errorf("%s is not a binary", binPath)
}

Prevention

When it happens

Trigger: Calling AllDependencies (or AllExeDependencies after path resolution) on a script (#!/bin/sh), a text/config file, a symlink target that is not a binary, or a corrupted/statically-unrecognizable file.

Common situations: Pointing the sensor at an interpreted app (Python/Node scripts) instead of its interpreter binary; app_name resolves to a shell wrapper; inspecting data files by mistake.

Related errors


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

Appendix: source

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

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)