{"record":{"id":"6f962b691f4374d7","repo":"mudler/LocalAI","slug":"moss-transcribe-cpp-dlopen-q-w","errorCode":null,"errorMessage":"moss-transcribe-cpp: dlopen %q: %w","messagePattern":"moss-transcribe-cpp: dlopen %q: %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/go/moss-transcribe-cpp/main.go","lineNumber":42,"sourceCode":"\ntype LibFuncs struct {\n\tFuncPtr any\n\tName    string\n}\n\nfunc main() {\n\tlibName := os.Getenv(\"MOSS_TRANSCRIBE_LIBRARY\")\n\tif libName == \"\" {\n\t\tif runtime.GOOS == \"darwin\" {\n\t\t\tlibName = \"libmoss-transcribe.dylib\"\n\t\t} else {\n\t\t\tlibName = \"libmoss-transcribe.so\"\n\t\t}\n\t}\n\n\tlib, err := purego.Dlopen(libName, purego.RTLD_NOW|purego.RTLD_GLOBAL)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"moss-transcribe-cpp: dlopen %q: %w\", libName, err))\n\t}\n\n\t// Bound 1:1 to moss_transcribe_capi.h. The transcribe_* entry points return\n\t// a malloc'd char* the caller owns; we register those as uintptr so we get\n\t// the raw pointer back and can call moss_transcribe_capi_free_string on it\n\t// (purego's string return would copy and forget the original pointer,\n\t// leaking it on every call).\n\tlibFuncs := []LibFuncs{\n\t\t{&CppAbiVersion, \"moss_transcribe_capi_abi_version\"},\n\t\t{&CppLoad, \"moss_transcribe_capi_load\"},\n\t\t{&CppFree, \"moss_transcribe_capi_free\"},\n\t\t{&CppTranscribePath, \"moss_transcribe_capi_transcribe_path\"},\n\t\t{&CppTranscribePcm, \"moss_transcribe_capi_transcribe_pcm\"},\n\t\t{&CppFreeString, \"moss_transcribe_capi_free_string\"},\n\t\t{&CppLastError, \"moss_transcribe_capi_last_error\"},\n\t}\n\tfor _, lf := range libFuncs {\n\t\tpurego.RegisterLibFunc(lf.FuncPtr, lib, lf.Name)","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/moss-transcribe-cpp/main.go#L24-L60","documentation":"Startup panic of the Go moss-transcribe-cpp backend when purego.Dlopen cannot load the Moss transcription library. Name comes from MOSS_TRANSCRIBE_LIBRARY, defaulting to libmoss-transcribe.dylib (macOS) or libmoss-transcribe.so (Linux). Loaded with RTLD_NOW so unresolved symbols also surface here as a dlopen error.","triggerScenarios":"Starting moss-transcribe-cpp with the native lib missing from the loader path, MOSS_TRANSCRIBE_LIBRARY pointing at a stale or wrong-architecture build, or the .so's own dependencies (whisper/ffmpeg etc.) unavailable at runtime.","commonSituations":"Skipping the C++ build step; running on a host with older glibc than the build machine; mixed arm64/amd64 binaries copied between machines; env var set in a wrapper script that is not propagated to the service unit.","solutions":["Confirm the library file exists at the resolved path (check MOSS_TRANSCRIBE_LIBRARY and the platform default name)","Rebuild libmoss-transcribe from the backend's build recipe on the target host","Point MOSS_TRANSCRIBE_LIBRARY at the absolute path of the freshly built library","Use ldd/otool -L to find and install missing transitive dependencies"],"exampleFix":"# before\n./moss-transcribe-cpp  # panic: moss-transcribe-cpp: dlopen \"libmoss-transcribe.so\": ...\n# after\nMOSS_TRANSCRIBE_LIBRARY=/opt/localai/backends/libmoss-transcribe.so ./moss-transcribe-cpp","handlingStrategy":"validation","validationCode":"lib := os.Getenv(\"MOSS_TRANSCRIBE_LIBRARY\"); if lib == \"\" { lib = defaultLibName() }\nif _, err := os.Stat(lib); err != nil { log.Fatalf(\"moss-transcribe-cpp: library %q missing: %v\", lib, err) }","typeGuard":"func libAvailable(path string) bool { _, err := os.Stat(path); return err == nil }","tryCatchPattern":null,"preventionTips":["Keep MOSS_TRANSCRIBE_LIBRARY absolute and stable across restarts","Build the native lib on the target OS/arch","Check transitive deps with ldd during image build"],"tags":["dlopen","native-library","go","backend","environment"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}