elkowar/eww · error

CSS error

Error message

CSS error: {}

What it means

load_css compiles the user's stylesheet (CSS/SCSS) and surfaces any compile error from the grass parser. When the error carries span/line information, eww renders a rich diagnostic; otherwise it falls back to this plain 'CSS error: {}' wrapping the parser's message.

Solutions

  1. Read the parser message after 'CSS error:' to locate the bad rule and fix the syntax
  2. If a diagnostic with a line number was printed instead, go to that line in the stylesheet
  3. Validate the file with a SCSS/CSS linter or a standalone grass/sass compile before reloading

Example fix

/* before */
.foo { color: ; }

/* after */
.foo { color: #ff0000; }
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate stylesheet with grass/sass before reload
npx sass --no-source-map ~/.config/eww/eww.scss > /dev/null && echo OK

Try / catch

// rust: surface diagnostics with context
if let Err(err) = app.load_css(path) {
    eprintln!("failed to load stylesheet: {err:#}");
}

Prevention

When it happens

Trigger: Calling load_css (during server initialization or a `reload` command) with a stylesheet that fails grass's compilation: bad selectors, unbalanced braces, invalid property values, or unparseable SCSS syntax.

Common situations: Hand-edited eww.scss/eww.css with a syntax mistake; SCSS features unsupported by the grass crate; stray characters pasted into the stylesheet; a failed reload after a config edit.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of elkowar/eww@48f5aa8b37 (2026-09-08). Data as JSON: /api/errors/6a6aec151f67281d. Report an issue: GitHub.

Appendix: source

Thrown at crates/eww/src/app.rs:604

        Ok(())
    }

    /// Load a given CSS string into the gtk css provider, returning a nicely formatted [`DiagError`] when GTK errors out
    pub fn load_css(&mut self, file_id: usize, css: &str) -> Result<()> {
        if let Err(err) = self.css_provider.load_from_data(css.as_bytes()) {
            static PATTERN: Lazy<regex::Regex> = Lazy::new(|| regex::Regex::new(r"[^:]*:(\d+):(\d+)(.*)$").unwrap());
            let nice_error_option: Option<_> = (|| {
                let captures = PATTERN.captures(err.message())?;
                let line = captures.get(1).unwrap().as_str().parse::<usize>().ok()?;
                let msg = captures.get(3).unwrap().as_str();
                let db = error_handling_ctx::FILE_DATABASE.read().ok()?;
                let line_range = db.line_range(file_id, line - 1).ok()?;
                let span = Span(line_range.start, line_range.end - 1, file_id);
                Some(DiagError(gen_diagnostic!(msg, span)))
            })();
            match nice_error_option {
                Some(error) => Err(anyhow!(error)),
                None => Err(anyhow!("CSS error: {}", err.message())),
            }
        } else {
            Ok(())
        }
    }
}

fn initialize_window<B: DisplayBackend>(
    window_init: &WindowInitiator,
    monitor: Monitor,
    root_widget: gtk::Widget,
    window_scope: ScopeIndex,
) -> Result<EwwWindow> {
    let monitor_geometry = monitor.geometry();
    let (actual_window_rect, x, y) = match window_init.geometry {
        Some(geometry) => {
            let rect = get_window_rectangle(geometry, monitor_geometry);
            (Some(rect), rect.x(), rect.y())

View on GitHub (pinned to 48f5aa8b37)