{"record":{"id":"30e3a084f88db760","repo":"Tencent/matrix","slug":"can-t-find-the-parser-driver-template-file-s","errorCode":null,"errorMessage":"Can't find the parser driver template file \"%s\".\n","messagePattern":"Can't find the parser driver template file \"(.+?)\"\\.\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-sqlite-lint/src/lemon/lemon-gen/lemon.c","lineNumber":3003,"sourceCode":"  FILE *in;\n  char *tpltname;\n  char *cp;\n\n  cp = strrchr(lemp->filename,'.');\n  if( cp ){\n    sprintf(buf,\"%.*s.lt\",(int)(cp-lemp->filename),lemp->filename);\n  }else{\n    sprintf(buf,\"%s.lt\",lemp->filename);\n  }\n  if( access(buf,004)==0 ){\n    tpltname = buf;\n  }else if( access(templatename,004)==0 ){\n    tpltname = templatename;\n  }else{\n    tpltname = pathsearch(lemp->argv0,templatename,0);\n  }\n  if( tpltname==0 ){\n    fprintf(stderr,\"Can't find the parser driver template file \\\"%s\\\".\\n\",\n    templatename);\n    lemp->errorcnt++;\n    return 0;\n  }\n  in = fopen(tpltname,\"rb\");\n  if( in==0 ){\n    fprintf(stderr,\"Can't open the template file \\\"%s\\\".\\n\",templatename);\n    lemp->errorcnt++;\n    return 0;\n  }\n  return in;\n}\n\n/* Print a #line directive line to the output file. */\nPRIVATE void tplt_linedir(out,lineno,filename)\nFILE *out;\nint lineno;\nchar *filename;","sourceCodeStart":2985,"sourceCodeEnd":3021,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-sqlite-lint/src/lemon/lemon-gen/lemon.c#L2985-L3021","documentation":"Lemon locates its parser driver template (lempar.c) by checking -T paths, the current directory, or via pathsearch against argv0. If no readable copy is found, it prints 'Can't find the parser driver template file \"lempar.c\".', increments errorcnt and aborts generation.","triggerScenarios":"Running lemon without a -T flag where lempar.c is not in the current directory nor next to the lemon executable; the -T argument names a template that fails the access(READ) check; lempar.c deleted from the installed toolchain directory.","commonSituations":"Installing/copying the lemon binary without shipping lempar.c alongside; running lemon from a different working directory (relative lookup fails); packaging matrix-sqlite-lint's build in a container without the lemon-gen template files; misspelled -T path.","solutions":["Pass the template explicitly: lemon -T /path/to/lempar.c grammar.y","Copy lempar.c into the directory where you invoke lemon","Ensure lempar.c sits in the same directory as the lemon binary (pathsearch target)","Fix the -T argument spelling/permissions (file must be readable, access(004))"],"exampleFix":"// before\nlemon parser.y\n// after\nlemon -T src/lemon-gen/lempar.c parser.y","handlingStrategy":"validation","validationCode":"#!/bin/sh\nTPL=${LEMON_TEMPLATE:-$(dirname \"$0\")/lempar.c}\nif [ ! -r \"$TPL\" ]; then echo \"template missing: $TPL\"; exit 1; fi\nlemon -T \"$TPL\" parser.y","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass -T with an absolute path to lempar.c","Package lempar.c together with the lemon binary in build images","Verify template presence in CI setup steps","Run lemon from the repo's lemon-gen directory if relying on relative lookup"],"tags":["lemon","template","file-not-found","build-tool"],"backgroundTag":"file-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"}