{"record":{"id":"f35d1bab9ed6b47a","repo":"Tencent/matrix","slug":"can-not-find-the-tool-nm","errorCode":null,"errorMessage":"---Can not find the tool 'nm'!","messagePattern":"---Can not find the tool 'nm'!","errorType":"validation","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/MultiSTLCheckTask.java","lineNumber":83,"sourceCode":"        toolnmPath = params.get(JobConstants.PARAM_TOOL_NM);\n        if (Util.isNullOrNil(toolnmPath)) {\n            throw new TaskInitException(TAG + \"---The path of tool 'nm' is not given!\");\n        } else {\n            Pattern envPattern = Pattern.compile(\"(\\\\$[a-zA-Z_-]+)\");\n            Matcher matcher =  envPattern.matcher(toolnmPath);\n            while (matcher.find()) {\n                if (!Util.isNullOrNil(matcher.group())) {\n                    String env = System.getenv(matcher.group().substring(1));\n                    Log.d(TAG, \"%s -> %s\", matcher.group().substring(1), env);\n                    if (!Util.isNullOrNil(env)) {\n                        toolnmPath = toolnmPath.replace(matcher.group(), env);\n                    }\n                }\n            }\n            Log.i(TAG, \"toolnm pah is %s\", toolnmPath);\n        }\n        if (!FileUtil.isLegalFile(toolnmPath)) {\n            throw new TaskInitException(TAG + \"---Can not find the tool 'nm'!\");\n        }\n        if (!Util.isNullOrNil(inputPath)) {\n            Log.i(TAG, \"inputPath:%s\", inputPath);\n            libDir = new File(inputPath, \"lib\");\n        } else {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n\n    }\n\n    private boolean isStlLinked(File libFile) throws IOException, InterruptedException {\n        ProcessBuilder processBuilder = new ProcessBuilder(toolnmPath, \"-D\", \"-C\", libFile.getAbsolutePath());\n        Process process = processBuilder.start();\n        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));\n        String line = reader.readLine();\n        while (line != null) {\n            String[] columns = line.split(\" \");\n            Log.d(TAG, \"%s\", line);","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/MultiSTLCheckTask.java#L65-L101","documentation":"After resolving (including env-var interpolation of paths like $VAR), MultiSTLCheckTask.init() checks FileUtil.isLegalFile(toolnmPath). If the nm tool path does not point to an existing legal file, it throws TaskInitException with this message.","triggerScenarios":"PARAM_TOOL_NM is set but the path does not exist or is not a regular file: wrong NDK version path, nm binary not installed, or an embedded $ENV_VAR failed to resolve (env var unset) leaving a bogus path.","commonSituations":"CI image without the Android NDK installed; $ANDROID_NDK or similar env var missing so interpolation yields an invalid path; macOS vs Linux toolchain path mix-ups; NDK upgrade changed tool layout (prebuilt/<abi>/ vs llvm-nm).","solutions":["Verify the nm path exists: ls the exact configured path; fix it to the real binary location.","Install the Android NDK / command-line tools containing nm (llvm-nm).","Check that environment variables referenced in the path (e.g. $ANDROID_NDK_HOME) are exported in the process environment."],"exampleFix":"// before\nparams.put(JobConstants.PARAM_TOOL_NM, \"$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/nm\"); // removed in new NDK\n// after\nparams.put(JobConstants.PARAM_TOOL_NM, System.getenv(\"ANDROID_NDK_HOME\") + \"/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-nm\");","handlingStrategy":"validation","validationCode":"String nm = params.get(JobConstants.PARAM_TOOL_NM);\nFile nmFile = new File(nm);\nif (!nmFile.isFile() || !nmFile.canExecute()) {\n    throw new IllegalStateException(\"nm tool not found or not executable: \" + nm);\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    if (e.getMessage().contains(\"Can not find the tool 'nm'\")) {\n        // fix path: verify NDK installation and env-var interpolation\n    }\n}","preventionTips":["ls the exact nm path in CI before running the checker.","Install the Android NDK on machines that run STL checks.","Expand/verify env vars (e.g. $ANDROID_NDK_HOME) yourself rather than relying on the task's interpolation.","After NDK upgrades, update tool paths (llvm-nm replaced old prebuilt nm)."],"tags":["external-tool","file-not-found","ndk"],"backgroundTag":"command-not-found","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}