microsoft/typescript-go · critical
bundled: %v does not exist; this executable may be misplaced
Error message
bundled: %v does not exist; this executable may be misplaced
What it means
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.
Source
Thrown at internal/bundled/noembed.go:40
var executableDir = sync.OnceValue(func() string {
exe, err := osutil.Executable()
if err != nil {
panic(fmt.Sprintf("bundled: failed to get executable path: %v", err))
}
exe = tspath.NormalizeSlashes(exe)
exe = osvfs.FS().Realpath(exe)
return tspath.GetDirectoryPath(exe)
})
var libPath = sync.OnceValue(func() string {
if testing.Testing() {
return TestingLibPath()
}
dir := executableDir()
libdts := tspath.CombinePaths(dir, "lib.d.ts")
if info := osvfs.FS().Stat(libdts); info == nil {
panic(fmt.Sprintf("bundled: %v does not exist; this executable may be misplaced", libdts))
}
return dir
})
func IsBundled(path string) bool {
return false
}
View on GitHub (pinned to 1bcfa18d79)
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
Example fix
# before COPY bin/tsc /usr/local/bin/ RUN tsc --version # panics: no /usr/local/lib.d.ts # after: ship the whole distribution (exe + lib.d.ts siblings) COPY dist/ /opt/tsgo/ RUN ln -s /opt/tsgo/tsgo /usr/local/bin/tsgo
Defensive patterns
Strategy: validation
Validate before calling
// Run before any compiler use: verify the noembed distribution is intact.
func checkBundledLibs(exeDir string) error {
if _, err := os.Stat(filepath.Join(exeDir, "lib.d.ts")); err != nil {
return fmt.Errorf("lib.d.ts missing next to executable %s; ship the full distribution or use the embedded build: %w", exeDir, err)
}
return nil
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unknown callback name: %s
- -32603
- -32603
- api: failed to write panic error response: %v (original pani
- api: failed to write response: %v
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/35c9d732020b9a9b.
Report an issue: GitHub.