glanceapp/glance · error
units must be either metric or imperial
Error message
units must be either metric or imperial
What it means
Returned by weatherWidget.initialize() when the weather widget's units value is neither empty, 'metric', nor 'imperial'. The field controls whether Open-Meteo forecasts render in °C/mm vs °F/inches. It fails fast at config-load time, wrapped as 'weather widget: units must be either metric or imperial'.
Source
Thrown at internal/glance/widget-weather.go:53
func (widget *weatherWidget) initialize() error {
widget.withTitle("Weather").withCacheOnTheHour()
if widget.Location == "" {
return fmt.Errorf("location is required")
}
if widget.HourFormat == "" || widget.HourFormat == "12h" {
widget.TimeLabels = timeLabels12h
} else if widget.HourFormat == "24h" {
widget.TimeLabels = timeLabels24h
} else {
return errors.New("hour-format must be either 12h or 24h")
}
if widget.Units == "" {
widget.Units = "metric"
} else if widget.Units != "metric" && widget.Units != "imperial" {
return errors.New("units must be either metric or imperial")
}
return nil
}
func (widget *weatherWidget) update(ctx context.Context) {
if widget.Place == nil {
place, err := fetchOpenMeteoPlaceFromName(widget.Location)
if err != nil {
widget.withError(err).scheduleEarlyUpdate()
return
}
widget.Place = place
}
weather, err := fetchWeatherForOpenMeteoPlace(widget.Place, widget.Units)
View on GitHub (pinned to 91324e8de7)
Solutions
- Use units: metric or units: imperial exactly, or omit the key (defaults to metric).
- Run `glance config:validate --config glance.yml` after editing to catch it before restart.
- Double-check YAML quoting and casing.
Example fix
// glance.yml (before) - type: weather location: Tokyo, Japan units: celsius // after - type: weather location: Tokyo, Japan units: metric
Defensive patterns
Strategy: validation
Validate before calling
grep -n 'units:' glance.yml | grep -vE 'units:\s*(metric|imperial)\s*$' && echo 'BAD units' && exit 1 || echo ok
Prevention
- Use only 'metric' or 'imperial' (or omit for metric default).
- Never write temperature-scale names like celsius/fahrenheit.
- Validate config with `glance config:validate` before restart.
When it happens
Trigger: YAML config has a weather widget with units: celsius, units: fahrenheit, units: Metric (capitalized), units: SI, or any other string — only '', 'metric', 'imperial' are accepted.
Common situations: Intuitively writing 'celsius'/'fahrenheit' instead of the unit system name; capitalized 'Metric'; copying config snippets from blog posts that use wrong values.
Related errors
- hour-format must be either 12h or 24h
- location is required
- URL is required
- nested groups are not supported
- split columns inside of groups are not supported
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/dd465c2cbdac1014.
Report an issue: GitHub.