{"record":{"id":"97d96d9f4d9654c1","repo":"router-for-me/CLIProxyAPI","slug":"standard-dynamic-library-plugin-loading-requires-c","errorCode":null,"errorMessage":"standard dynamic library plugin loading requires cgo on this platform: %s","messagePattern":"standard dynamic library plugin loading requires cgo on this platform: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/loader_unsupported.go","lineNumber":10,"sourceCode":"//go:build !cgo && !windows\n\npackage pluginhost\n\nimport \"fmt\"\n\ntype unsupportedLoader struct{}\n\nfunc (unsupportedLoader) Open(file pluginFile, host *Host) (pluginClient, error) {\n\treturn nil, fmt.Errorf(\"standard dynamic library plugin loading requires cgo on this platform: %s\", file.Path)\n}\n\nfunc defaultPluginLoader() pluginLoader {\n\treturn unsupportedLoader{}\n}\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/loader_unsupported.go#L1-L16","documentation":"The binary was compiled with CGO_ENABLED=0 (or no C compiler) on a non-Windows platform, so the pluginhost cannot load dynamic-library plugins. The unsupportedLoader stub is selected at build time via the !cgo && !windows build tag and rejects every Open() with this message.","triggerScenarios":"Building with CGO_ENABLED=0 (common in Docker scratch/alpine images and distroless CI); missing gcc/clang in the build container; cross-compiling without a C toolchain for the target platform; then configuring any plugin with a .so library path.","commonSituations":"Docker images that set CGO_ENABLED=0 for static binaries; GoReleaser defaults that disable cgo; development on a machine without build-essential installed.","solutions":["Rebuild with CGO_ENABLED=1 and a working C compiler (e.g. apt-get install gcc / apk add build-base) installed","For cross-compilation, install a cross C toolchain (e.g. musl-gcc) and set CC accordingly","If dynamic-library plugins are not needed, remove plugin entries from the config so the loader is never invoked"],"exampleFix":"# before\ndocker build  # Dockerfile: ENV CGO_ENABLED=0\n\n# after\n# Dockerfile\nENV CGO_ENABLED=1\nRUN apk add --no-cache build-base","handlingStrategy":"validation","validationCode":"// At startup, before serving:\nif runtime.GOOS != \"windows\" && !cgoAvailable() {\n    if len(cfg.Plugins) > 0 {\n        log.Fatal(\"plugins configured but binary built without cgo; rebuild with CGO_ENABLED=1\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set CGO_ENABLED=1 explicitly in build scripts and Dockerfiles when plugins are used","Install a C compiler in CI images (gcc / build-base / mingw)","Fail fast at startup if plugins are configured but the loader is the unsupported stub"],"tags":["plugin","cgo","build","dynamic-library"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}