{"record":{"id":"dad4df481493cbad","repo":"gohugoio/hugo","slug":"inject-file-q-not-found","errorCode":null,"errorMessage":"inject: file %q not found","messagePattern":"inject: file %q not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/esbuild/build.go","lineNumber":93,"sourceCode":"\n\tvar err error\n\topts.compiled.Plugins, err = createBuildPlugins(c.rs, assetsResolver, dependencyManager, opts)\n\tif err != nil {\n\t\treturn api.BuildResult{}, err\n\t}\n\n\tif opts.Inject != nil {\n\t\t// Resolve the absolute filenames.\n\t\tfor i, ext := range opts.Inject {\n\t\t\timpPath := filepath.FromSlash(ext)\n\t\t\tif filepath.IsAbs(impPath) {\n\t\t\t\treturn api.BuildResult{}, fmt.Errorf(\"inject: absolute paths not supported, must be relative to /assets\")\n\t\t\t}\n\n\t\t\tm := assetsResolver.resolveComponent(impPath, false)\n\n\t\t\tif m == nil {\n\t\t\t\treturn api.BuildResult{}, fmt.Errorf(\"inject: file %q not found\", ext)\n\t\t\t}\n\n\t\t\topts.Inject[i] = m.Filename\n\n\t\t}\n\n\t\topts.compiled.Inject = opts.Inject\n\n\t}\n\n\tresult := api.Build(opts.compiled)\n\n\tif len(result.Errors) > 0 {\n\t\tcreateErr := func(msg api.Message) error {\n\t\t\tif msg.Location == nil {\n\t\t\t\treturn errors.New(msg.Text)\n\t\t\t}\n\t\t\tvar (","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/js/esbuild/build.go#L75-L111","documentation":"Returned when an Inject entry cannot be resolved by the assets filesystem resolver: assetsResolver.resolveComponent returned nil. The path was relative but no matching file (with or without common extensions) exists under any configured /assets root.","triggerScenarios":"Passing opts.Inject = []string{\"shims.js\"} when assets/shims.js does not exist. ResolveComponent also tries shims.ts, shims.tsx, shims.jsx, etc., so the file must be entirely absent.","commonSituations":"Typo in the inject path; file lives in a different asset folder not mounted by Hugo modules; file exists only in a module that isn't imported; case-sensitivity mismatch (works on macOS, fails on Linux).","solutions":["Confirm the file exists under one of your configured /assets directories.","Use the exact filename including extension.","Check that module mounts include the assets folder the file lives in.","Verify filename case matches on case-sensitive filesystems."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before Build, confirm each inject path resolves under the assets fs.\nfor _, p := range opts.Inject {\n    if fi, err := assetsFs.Stat(p); err != nil || fi.IsDir() {\n        return fmt.Errorf(\"inject file not found in /assets: %q\", p)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exact filenames including extension in inject paths.","Verify module mounts include the assets folder the file lives in.","Test on a case-sensitive filesystem (Linux) to catch case mismatches early."],"tags":["esbuild","inject","assets","config"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}