{"record":{"id":"35c9d732020b9a9b","repo":"microsoft/typescript-go","slug":"bundled-v-does-not-exist-this-executable-may-be","errorCode":null,"errorMessage":"bundled: %v does not exist; this executable may be misplaced","messagePattern":"bundled: (.+?) does not exist; this executable may be misplaced","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/bundled/noembed.go","lineNumber":40,"sourceCode":"var executableDir = sync.OnceValue(func() string {\n\texe, err := osutil.Executable()\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"bundled: failed to get executable path: %v\", err))\n\t}\n\texe = tspath.NormalizeSlashes(exe)\n\texe = osvfs.FS().Realpath(exe)\n\treturn tspath.GetDirectoryPath(exe)\n})\n\nvar libPath = sync.OnceValue(func() string {\n\tif testing.Testing() {\n\t\treturn TestingLibPath()\n\t}\n\tdir := executableDir()\n\n\tlibdts := tspath.CombinePaths(dir, \"lib.d.ts\")\n\tif info := osvfs.FS().Stat(libdts); info == nil {\n\t\tpanic(fmt.Sprintf(\"bundled: %v does not exist; this executable may be misplaced\", libdts))\n\t}\n\n\treturn dir\n})\n\nfunc IsBundled(path string) bool {\n\treturn false\n}\n","sourceCodeStart":22,"sourceCodeEnd":49,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/bundled/noembed.go#L22-L49","documentation":"In the noembed build (libs shipped as external files instead of embedded in the binary), libPath() panics when it cannot find a 'lib.d.ts' file next to the executable directory. This is a deployment-integrity panic raised lazily via sync.OnceValue: the first use of bundled library files aborts the process, not returns an error.","triggerScenarios":"Running the compiled noembed binary after moving/copying it away from its lib directory; Docker images or install scripts that ship only the executable; invoking with a cwd that is not the binary's directory while the lib directory was left behind; test binaries that do not set up TestingLibPath.","commonSituations":"CI pipelines copying a single binary artifact into a slim image; 'go build' output moved to /usr/local/bin without ../lib.d.ts; renaming or repackaging the distribution so exe and lib.d.ts are no longer siblings.","solutions":["Keep the executable in its original directory so lib.d.ts sits next to it (exe_dir/lib.d.ts must exist)","Or rebuild with the embedded-libs build tag so library files are compiled into the binary and no external file is needed","For tests, ensure the test setup provides the testing lib path (testing.Testing() branch) — do not run library-needing code before setup","In container images, COPY the whole distribution directory, not just the binary"],"exampleFix":"# before\nCOPY bin/tsc /usr/local/bin/\nRUN tsc --version   # panics: no /usr/local/lib.d.ts\n\n# after: ship the whole distribution (exe + lib.d.ts siblings)\nCOPY dist/ /opt/tsgo/\nRUN ln -s /opt/tsgo/tsgo /usr/local/bin/tsgo","handlingStrategy":"validation","validationCode":"// Run before any compiler use: verify the noembed distribution is intact.\nfunc checkBundledLibs(exeDir string) error {\n    if _, err := os.Stat(filepath.Join(exeDir, \"lib.d.ts\")); err != nil {\n        return fmt.Errorf(\"lib.d.ts missing next to executable %s; ship the full distribution or use the embedded build: %w\", exeDir, err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deploy the whole distribution directory (binary + lib.d.ts siblings); never copy just the executable","Prefer embedded-lib build tags for single-file deployments (scratch containers, go install consumers)","Add a smoke test (`--version`) to Dockerfiles/CI so a misplaced binary fails fast with a clear cause","In tests, use the testing lib path hook instead of relying on binary location"],"tags":["bundling","deployment","panic","lib-d-ts","noembed"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}