JanDeDobbeleer/oh-my-posh · error
no location configured: set city+country or latitude+longitu
Error message
no location configured: set city+country or latitude+longitude
What it means
The ramadan segment builds an Aladhan API URL from either city+country or latitude+longitude. buildURL raises this error when city+country are not both set and either latitude or longitude is missing entirely from the options, because it cannot form any location query.
Source
Thrown at src/segments/ramadan.go:225
method := r.options.Int(RamadanMethod, 3)
school := r.options.Int(RamadanSchool, 0)
city := r.options.String(RamadanCity, "")
country := r.options.String(RamadanCountry, "")
if city != "" && country != "" {
return fmt.Sprintf(
"https://api.aladhan.com/v1/timingsByCity/%s?city=%s&country=%s&method=%d&school=%d",
date,
url.QueryEscape(city),
url.QueryEscape(country),
method,
school,
), nil
}
if r.options.Any(RamadanLatitude, nil) == nil || r.options.Any(RamadanLongitude, nil) == nil {
return "", errors.New("no location configured: set city+country or latitude+longitude")
}
lat := r.options.Float64(RamadanLatitude, 0)
lng := r.options.Float64(RamadanLongitude, 0)
return fmt.Sprintf(
"https://api.aladhan.com/v1/timings/%s?latitude=%g&longitude=%g&method=%d&school=%d",
date, lat, lng, method, school,
), nil
}
// Returns whether today is in Ramadan and the roza (day) number. When first_roza_date is
// set it overrides the API's Hijri month detection.
func (r *Ramadan) resolveRamadanDay(now time.Time, data ramadanData, firstRozaStr string) (bool, int) {
if firstRozaStr != "" {
firstRoza, err := time.ParseInLocation("2006-01-02", firstRozaStr, now.Location())
if err == nil {
// Use UTC noon arithmetic to avoid DST off-by-one errors.View on GitHub (pinned to 0976794618)
Solutions
- Set both city and country (city+country takes precedence when both present).
- Or set both latitude and longitude as numbers.
- Remember partial pairs are rejected: city without country, or lat without lng, still fails.
- Check for template/typo issues in option names (e.g. "latitude" not "lat").
Example fix
// before "type": "ramadan", "city": "Karachi" // after "type": "ramadan", "city": "Karachi", "country": "Pakistan" // or: "latitude": 24.86, "longitude": 67.0
Defensive patterns
Strategy: validation
Validate before calling
const hasCity = Boolean(cfg.city && cfg.country)
const hasCoords = cfg.latitude != null && cfg.longitude != null
if (!hasCity && !hasCoords) {
throw new Error("ramadan segment: provide city+country or latitude+longitude")
} Try / catch
if err := r.setData(); err != nil {
if strings.Contains(err.Error(), "no location configured") {
log.Warn("ramadan: configure city+country or latitude+longitude")
return false // hide segment
}
return false
} Prevention
- Provide complete pairs: city AND country, or latitude AND longitude.
- Remember city+country wins when both forms are set; don't mix partials.
- Use option names exactly as documented: latitude, longitude, city, country.
- There is no IP-based geolocation fallback — always configure a location explicitly.
When it happens
Trigger: Configuring a ramadan segment with only city (no country), only country (no city), only latitude (no longitude), only longitude (no latitude), or none of the four options at all.
Common situations: Users assuming city alone suffices, copying a config and deleting one half of a coordinate pair, or omitting all location options expecting IP-based geolocation (the segment does not do that).
Related errors
- missing Brewfather api key (api_key)
- missing Brewfather batch id (batch_id)
- no location found
- source file %s does not match format %s
- pulumi stack name is empty, use `fetch_stack` property to en
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/aecd25920aad3010.
Report an issue: GitHub.