containerd/containerd · error

set binary lib directory in path %s: %w

Error message

set binary lib directory in path %s: %w

What it means

Same initialization flow as 1836 but for LD_LIBRARY_PATH: after creating <path>/lib, prepending it to LD_LIBRARY_PATH via os.Setenv failed and the os error is wrapped. The opt plugin init aborts, so binary image libs are not available.

Source

Thrown at plugins/services/opt/service.go:58

			Path: defaultPath,
		},
		InitFn: func(ic *plugin.InitContext) (any, error) {
			path := ic.Config.(*Config).Path
			ic.Meta.Exports["path"] = path
			bin := filepath.Join(path, "bin")
			if err := os.MkdirAll(bin, 0711); err != nil {
				return nil, err
			}
			if err := os.Setenv("PATH", fmt.Sprintf("%s%c%s", bin, os.PathListSeparator, os.Getenv("PATH"))); err != nil {
				return nil, fmt.Errorf("set binary image directory in path %s: %w", bin, err)
			}

			lib := filepath.Join(path, "lib")
			if err := os.MkdirAll(lib, 0711); err != nil {
				return nil, err
			}
			if err := os.Setenv("LD_LIBRARY_PATH", fmt.Sprintf("%s%c%s", lib, os.PathListSeparator, os.Getenv("LD_LIBRARY_PATH"))); err != nil {
				return nil, fmt.Errorf("set binary lib directory in path %s: %w", lib, err)
			}
			return &manager{}, nil
		},
	})
}

type manager struct {
}

View on GitHub (pinned to 4246446a2b)

Solutions

  1. Check the wrapped os error and fix the underlying Setenv failure.
  2. Run containerd with a standard environment allowing LD_LIBRARY_PATH modification.
  3. If embedding, do not strip or freeze the env before plugin initialization.
  4. Restart containerd after correcting the environment.

Example fix

// before
// LD_LIBRARY_PATH stripped for hardening
env = stripSensitiveVars(os.Environ())
// after
// preserve LD_LIBRARY_PATH so opt plugin init can prepend its lib dir
env = append(os.Environ(), "LD_LIBRARY_PATH="+libPath)
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil && strings.Contains(err.Error(), "set binary lib directory") {
    log.Fatalf("opt plugin env init failed: %v", err)
}

Prevention

When it happens

Trigger: os.Setenv("LD_LIBRARY_PATH", ...) errors during opt plugin init (restricted environment or invalid env state).

Common situations: Embedded containerd with locked environment; LD_LIBRARY_PATH already huge (OS env size limit); hardened runtimes that forbid setenv for select variables.

Related errors


AI-assisted analysis of containerd/containerd@4246446a2b (2026-09-02). Data as JSON: /api/errors/e1fcc8ea75b5d522. Report an issue: GitHub.