{"record":{"id":"e6ffb50be02dafaa","repo":"alibaba/arthas","slug":"can-not-find-libasyncprofiler-so-please-check-the","errorCode":null,"errorMessage":"Can not find libasyncProfiler so, please check the arthas directory.","messagePattern":"Can not find libasyncProfiler so, please check the arthas directory\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java","lineNumber":583,"sourceCode":"            FileInputStream libInputStream = null;\n            try {\n                File tmpLibFile = File.createTempFile(VmTool.JNI_LIBRARY_NAME, null);\n                tmpLibOutputStream = new FileOutputStream(tmpLibFile);\n                libInputStream = new FileInputStream(libPath);\n\n                IOUtils.copy(libInputStream, tmpLibOutputStream);\n                libPath = tmpLibFile.getAbsolutePath();\n                logger.debug(\"copy {} to {}\", libPath, tmpLibFile);\n            } catch (Throwable e) {\n                logger.error(\"try to copy lib error! libPath: {}\", libPath, e);\n            } finally {\n                IOUtils.close(libInputStream);\n                IOUtils.close(tmpLibOutputStream);\n            }\n            profiler = AsyncProfiler.getInstance(libPath);\n        } else {\n            if (OSUtils.isLinux() || OSUtils.isMac()) {\n                throw new IllegalStateException(\"Can not find libasyncProfiler so, please check the arthas directory.\");\n            } else {\n                throw new IllegalStateException(\"Current OS do not support AsyncProfiler, Only support Linux/Mac.\");\n            }\n        }\n\n        return profiler;\n    }\n\n    /**\n     * https://github.com/async-profiler/async-profiler/blob/v4.4/src/arguments.cpp\n     */\n    public enum ProfilerAction {\n        // start, resume, stop, dump, status, meminfo, list,\n        start, resume, stop, dump, status, meminfo, list,\n        version,\n\n        load,\n        execute,","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java#L565-L601","documentation":"Thrown by profilerInstance() in the `profiler` command when running on Linux or macOS but the async-profiler native library (libasyncProfiler.so / .dylib) cannot be located in the arthas directory (libPath is null) and the action is not an explicit `load` from a custom path. Arthas bundles the native agent for supported platforms; if it is missing the profiler cannot start.","triggerScenarios":"Running `profiler start` (or status/resume/stop/etc.) on Linux/Mac when the bundled libasyncProfiler native library is absent from the arthas install directory. Occurs with stripped-down or partial arthas distributions, or when the working directory does not contain the lib.","commonSituations":"Using a minimal/custom arthas packaging that omits the native lib; running arthas from a directory that does not contain the async-profiler .so/.dylib; the lib file was deleted or not extracted; permissions issue preventing the lib from being read.","solutions":["Reinstall or re-download a full arthas distribution so libasyncProfiler.so (Linux) or .dylib (Mac) is present in the arthas directory.","Use `profiler load /absolute/path/to/libasyncProfiler.so` to point at a manually built/downloaded native lib.","Verify the file exists and is readable in the arthas working directory (ls the directory arthas was launched from).","Ensure the native lib matches your OS/arch (e.g. linux-x64)."],"exampleFix":"// before\nprofiler start\n// after\nprofiler load /opt/async-profiler/build/libasyncProfiler.so\nprofiler start","handlingStrategy":"try-catch","validationCode":"// Detect the native lib before invoking profiler actions\nFile lib = new File(arthasDir, System.mapLibraryName(\"asyncProfiler\"));\nif (!lib.exists() && !\"load\".equals(action)) {\n    System.err.println(\"Native lib missing; use `profiler load <path>`\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    profiler.start(...);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"libasyncProfiler\")) {\n        // load a custom lib then retry\n        profiler = AsyncProfiler.getInstance(\"/path/to/libasyncProfiler.so\");\n    } else throw e;\n}","preventionTips":["Ship/verify the bundled libasyncProfiler native lib with your arthas distribution.","Use `profiler load <abs-path>` for a custom-built native lib.","Match the native lib to your OS/arch."],"tags":["arthas","profiler","native-library","environment","async-profiler"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}