{"record":{"id":"b4d0124621e711e9","repo":"instructure/canvas-lms","slug":"you-must-run-webpack-first","errorCode":null,"errorMessage":"you must run \"webpack\" first","messagePattern":"you must run \"webpack\" first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"lib/canvas/cdn/registry/webpack.rb","lineNumber":67,"sourceCode":"          # contains -entry- in filename, ends in .js, but doesn't end in .map.js\n          all_entries = @manifest.values.grep(/-entry-.*\\.js$/).grep_v(/\\.map\\.js$/).map { |x| realpath(x) }\n\n          # partition entries into main and others\n          main_entry, other_entries = all_entries.partition { |x| x.include? \"main-entry\" }\n\n          # load other entries first, then main entry\n          other_entries + main_entry\n        end\n\n        private\n\n        def load_manifest_from_disk\n          file = Rails.root.join(\"public/#{@asset_dir}/webpack-manifest.json\")\n\n          if file.exist?\n            JSON.parse(file.read).freeze\n          elsif Rails.env.production?\n            raise \"you must run \\\"webpack\\\" first\"\n          else\n            {}\n          end\n        end\n\n        def realpath(vfile)\n          \"/#{@asset_dir}/#{vfile}\"\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":49,"sourceCodeEnd":80,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/canvas/cdn/registry/webpack.rb#L49-L80","documentation":"The webpack CDN registry reads public/<asset_dir>/webpack-manifest.json to translate logical js bundle names to fingerprinted output files. In production a missing manifest raises 'you must run \"webpack\" first'; dev returns {} so lookups degrade gracefully.","triggerScenarios":"Resolving any webpack-managed asset in production when public/<asset_dir>/webpack-manifest.json is absent because the webpack build never ran or its output was deleted.","commonSituations":"Deploying a production image without the webpack build stage; a failed/partial webpack run that left no manifest; cleaning public/ before serving; misconfigured @asset_dir.","solutions":["Run the webpack production build (yarn webpack) to emit webpack-manifest.json into the expected asset dir","Verify CONFIG/@asset_dir matches the directory the build writes to","Add the webpack build as a required step in the production image build","Check the manifest exists in a startup health check"],"exampleFix":"// before\nfile = Rails.root.join(\"public/#{@asset_dir}/webpack-manifest.json\") # missing -> raise in prod\n// after\n$ yarn webpack   # regenerates public/dist/webpack-manifest.json","handlingStrategy":"fallback","validationCode":"raise 'webpack manifest missing' unless Rails.root.join('public/dist/webpack-manifest.json').exist?","typeGuard":null,"tryCatchPattern":"begin\n  registry.load_manifest_from_disk\nrescue RuntimeError => e\n  raise unless e.message.include?('webpack')\n  {}\nend","preventionTips":["Make the webpack build a mandatory stage of the production image","Verify manifest presence before Rails boot","Keep @asset_dir in sync with the webpack output path"],"tags":["ruby","webpack","assets","manifest"],"backgroundTag":"missing-build-artifact","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}