{"record":{"id":"7ac99c01ad884c71","repo":"instructure/canvas-lms","slug":"file-expand-path-does-not-exist-you-need-to-run-yarn-run","errorCode":null,"errorMessage":"#{file.expand_path} does not exist. You need to run `yarn run build:css` before you can serve css.","messagePattern":"#(.+?) does not exist\\. You need to run `yarn run build:css` before you can serve css\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"lib/brandable_css.rb","lineNumber":286,"sourceCode":"      @variants ||= CONFIG[\"variants\"].keys.freeze\n    end\n\n    def brandable_variants\n      @brandable_variants ||= CONFIG[\"variants\"].select { |_, v| v[\"brandable\"] }.map { |k, _| k }.freeze\n    end\n\n    def combined_checksums\n      if defined?(ActionController) && ActionController::Base.perform_caching && defined?(@combined_checksums)\n        return @combined_checksums\n      end\n\n      file = APP_ROOT.join(CONFIG[\"paths\"][\"bundles_with_deps\"])\n      if file.exist?\n        @combined_checksums = JSON.parse(file.read).transform_values do |v|\n          v.symbolize_keys.slice(:combinedChecksum, :includesNoVariables)\n        end.freeze\n      elsif defined?(Rails) && Rails.env.production?\n        raise \"#{file.expand_path} does not exist. You need to run `yarn run build:css` before you can serve css.\"\n      else\n        # for dev/test there might be cases where you don't want it to raise an exception\n        # if you haven't ran `brandable_css` and the manifest file doesn't exist yet.\n        # eg: you want to test a controller action and you don't care that it links\n        # to a css file that hasn't been created yet.\n        default_value = { combinedChecksum: \"Error: unknown css checksum. you need to run brandable_css\" }.freeze\n        @combined_checksums = Hash.new(default_value).freeze\n      end\n    end\n\n    # javascript needs to know the checksums of the available variants for each\n    # handlebars template so that it loads the corresponding stylesheet when the\n    # template is rendered at runtime\n    def handlebars_index_json\n      if defined?(ActionController) && ActionController::Base.perform_caching && defined?(@handlebars_index_json)\n        return @handlebars_index_json\n      end\n","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/brandable_css.rb#L268-L304","documentation":"brandable_css reads a prebuilt manifest (bundles_with_deps JSON) produced by the frontend build to resolve css bundle checksums. In production it raises this error if that file is missing, because serving pages without built css would break all styling. Dev/test gets a placeholder checksum instead.","triggerScenarios":"Booting or serving a production Canvas instance whose public/dist css artifacts were never built — combined_checksums is invoked when APP_ROOT.join(CONFIG['paths']['bundles_with_deps']) does not exist and Rails.env.production?.","commonSituations":"Deploying from a checkout without running yarn run build:css; Docker/production image built without the frontend build step; clearing public/dist as part of a clean and then starting Rails.","solutions":["Run yarn run build:css (in the web container per repo conventions) to generate the manifests","Rebuild/republish the production Docker image including the frontend build artifacts","Verify the CONFIG['paths']['bundles_with_deps'] file exists after the build before starting Rails","In CI, add a step asserting the manifest file exists prior to deploy"],"exampleFix":"// before\nfile.exist? => false, Rails.env.production? => raise\n// after\n$ yarn run build:css   # regenerates public/dist/* and the checksum manifests","handlingStrategy":"fallback","validationCode":"path = APP_ROOT.join(CONFIG['paths']['bundles_with_deps'])\nraise 'css not built' unless path.exist?","typeGuard":null,"tryCatchPattern":"begin\n  BrandableCSS.combined_checksums\nrescue RuntimeError => e\n  raise unless e.message.include?('build:css')\n  fallback_checksum\nend","preventionTips":["Always run yarn run build:css before RAILS_ENV=production","Add manifest-existence assertion to deploy pipeline","Keep frontend build inside the production Dockerfile"],"tags":["ruby","css","build-artifacts","production"],"backgroundTag":"file-not-found","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"}