{"record":{"id":"9a1e3420f93ca533","repo":"BetterErrors/better_errors","slug":"the-sassc-gem-is-required-when-developing-the-b","errorCode":null,"errorMessage":"The `sassc` gem is required when developing the `better_errors` gem. If you're using a release of `better_errors`, the compiled CSS is missing from the released gem","messagePattern":"The `sassc` gem is required when developing the `better_errors` gem\\. If you're using a release of `better_errors`, the compiled CSS is missing from the released gem","errorType":"exception","errorClass":"LoadError","httpStatus":null,"severity":"error","filePath":"lib/better_errors/error_page_style.rb","lineNumber":8,"sourceCode":"module BetterErrors\n  # @private\n  module ErrorPageStyle\n    def self.compiled_css(for_deployment = false)\n      begin\n        require \"sassc\"\n      rescue LoadError\n        raise LoadError, \"The `sassc` gem is required when developing the `better_errors` gem. \"\\\n          \"If you're using a release of `better_errors`, the compiled CSS is missing from the released gem\"\n        # If you arrived here because sassc is not in your project's Gemfile,\n        # the issue here is that the release of the better_errors gem\n        # is supposed to contain the compiled CSS, but that file is missing from the release.\n        # So better_errors is trying to build the CSS on the fly, which requires the sassc gem.\n        #\n        # If you're developing the better_errors gem locally, and you're running a project\n        # that does not have sassc in its bundle, run `rake style:build` in the better_errors\n        # project to compile the CSS file.\n      end\n\n      style_dir = File.expand_path(\"style\", File.dirname(__FILE__))\n      style_file = \"#{style_dir}/main.scss\"\n\n      engine = SassC::Engine.new(\n        File.read(style_file),\n        filename: style_file,\n        style: for_deployment ? :compressed : :expanded,","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/BetterErrors/better_errors/blob/fde3b7025db17b5cda13fcf8d08dfb3f76e189f6/lib/better_errors/error_page_style.rb#L1-L26","documentation":"better_errors renders its error page from SCSS, and ships a precompiled CSS file inside released gems so end projects never need a Sass compiler. ErrorPageStyle.compiled_css first tries require \"sassc\" to compile the SCSS on the fly (the development path); when that require fails with LoadError, the gem re-raises this LoadError explaining the two possible root causes: you are developing better_errors locally without sassc in the bundle, or you are using a release where the compiled CSS file is missing from the gem package. In both cases the real problem is that the prebuilt stylesheet is absent and the on-the-fly compiler dependency is not installed.","triggerScenarios":"Calling BetterErrors::ErrorPageStyle.compiled_css (directly or by rendering a better_errors error page) in an environment where (a) lib/better_errors/style/*.css precompiled output is absent — typically a git checkout or a broken/edge gem build — and (b) the sassc gem is not in the bundle, so the require \"sassc\" fallback fails. Commonly hit by running specs or a Rails app against a git-sourced gem (gem \"better_errors\", github: ...), or after a release was packaged without running the CSS build step.","commonSituations":"Pointing the Gemfile at the better_errors GitHub repo instead of a released rubygems version; forking/developing the gem and running tests or a host app without the dev dependencies installed (bundle install with --without development); using an old or malformed gem package whose compiled CSS was excluded from the .gem; CI caches that strip generated files. Note sassc is a native extension, so even adding it can fail on systems without a C toolchain, which pushes users toward using precompiled releases instead.","solutions":["If you are using better_errors as a dependency (not hacking on it): switch to an official release from RubyGems (gem \"better_errors\", \"~> 2.10\" and bundle install) — releases ship the compiled CSS and never need sassc.","If you are developing better_errors locally: add sassc to the development group of the gem's Gemfile and run bundle install.","Alternatively, as a better_errors developer run `rake style:build` in the better_errors checkout to compile the CSS once, so the sassc require path is never taken.","If the error came from a git-sourced or locally-built gem, rebuild/reinstall the gem after the CSS build step so the packaged gem contains the compiled stylesheet.","Verify the fix: `ruby -e \"require 'sassc'\"` should succeed (dev setup), or confirm the compiled CSS file exists under lib/better_errors/style/ (release setup)."],"exampleFix":"# Gemfile (better_errors development checkout)\n# before\ngroup :development do\n  gem \"better_errors\", github: \"BetterErrors/better_errors\"\nend\n\n# after (option A - use a release with precompiled CSS)\ngroup :development do\n  gem \"better_errors\", \"~> 2.10\"\nend\n\n# after (option B - actually developing the gem, in better_errors' own Gemfile)\ngem \"development_deps\" # ensure dev group installed, then in the gem repo:\n#   bundle install        # pulls in sassc\n#   rake style:build      # or precompile the CSS once","handlingStrategy":"try-catch","validationCode":"def better_errors_css_available?\n  # Released gems ship precompiled CSS; check before touching sassc.\n  style_dir = File.expand_path(\"style\", Gem.loaded_specs[\"better_errors\"]&.full_gem_path.to_s)\n  require \"better_errors\"\n  dir = File.join(File.dirname(Gem.loaded_specs[\"better_errors\"].full_gem_path), \"lib\", \"better_errors\", \"style\")\n  Dir[File.join(dir, \"**\", \"*.css\")].any? || gem_available?(\"sassc\")\nend\n\ndef gem_available?(name)\n  !Gem.loaded_specs[name].nil? || Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n  false\nend","typeGuard":null,"tryCatchPattern":"begin\n  css = BetterErrors::ErrorPageStyle.compiled_css\nrescue LoadError => e\n  if e.message.include?(\"sassc\")\n    # Fall back: use a released better_errors gem with precompiled CSS,\n    # or install sassc (`gem install sassc` / add to Gemfile) and retry.\n    raise unless ENV[\"CI\"].nil? # decide policy: hard-fail vs degrade\n  else\n    raise\n  end\nend","preventionTips":["Pin better_errors to released RubyGems versions in app Gemfiles; avoid github:/path: sources for runtime gems whose packages embed build artifacts.","In the better_errors repo, keep sassc in the development group and run `rake style:build` before running specs or packaging a gem.","In CI for the gem itself, add a job step that verifies the packaged .gem contains the compiled CSS (gem build + inspect contents) so broken releases are caught before publish.","When bootstrapping a new dev machine, run bundle install with development groups enabled so native deps like sassc (needs a C toolchain) are present."],"tags":["ruby","better-errors","sassc","load-error","missing-dependency","native-extension"],"backgroundTag":"missing-gem-dependency","analyzedSha":"fde3b7025db17b5cda13fcf8d08dfb3f76e189f6","analyzedAt":"2026-08-21T18:46:19.030Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}