JanDeDobbeleer/oh-my-posh · info
environment access is disabled: rendering from recorded data
Error message
environment access is disabled: rendering from recorded data only
What it means
errDataOnly is the sentinel error guarding oh-my-posh's data-only (recorded) rendering mode, used e.g. under WASM where there is no filesystem. Instead of auditing every segment, the environment primitive methods themselves (StatFile, ResolveSymlink, RunCommandWithEnv, HTTPRequest, HasParentFilePath, etc.) refuse to execute and return this error, guaranteeing no segment can probe the real environment when rendering from recorded data.
Source
Thrown at src/runtime/terminal.go:137
term.cwd = correctPath(dir)
log.Debug(term.cwd)
}
// errDataOnly is what every environment probe answers with when
// Flags.DataOnly is set. DataOnly started life in config.Segment.restoreData,
// suppressing a segment the recorded data does not cover - but that only
// governs the segment's own Enabled(). A writer field computed lazily by a
// method the template calls still reached the machine long afterwards:
// segments/git.go's StashCount() reads logs/refs/stash off disk, and
// stashCount is unexported so no recorded data ever restores it. Rendering
// jandedobbeleer under wasm, where there is no filesystem, failed that
// template outright while the CLI happily read the real repository.
//
// Gating the environment itself rather than each such method is what makes
// the guarantee hold for segments nobody has audited: there is no way to
// write one that probes, because the probe primitives themselves refuse.
var errDataOnly = errors.New("environment access is disabled: rendering from recorded data only")
func (term *Terminal) HasFiles(pattern string) bool {
return term.HasFilesInDir(term.Pwd(), pattern)
}
func (term *Terminal) HasFilesInDir(dir, pattern string) bool {
if term.CmdFlags != nil && term.CmdFlags.DataOnly {
return false
}
defer log.Trace(time.Now(), pattern)
dirEntries, err := term.readDir(dir)
if err != nil {
log.Error(err)
log.Debug("false")
return false
}
View on GitHub (pinned to 0976794618)
Solutions
- Remove or replace segments that require live environment access (e.g. those using HasParentFilePath or command execution) when rendering from recorded data.
- Render in a real terminal/CLI instead of the data-only (WASM/editor) environment.
- If you are extending the code, provide recorded data for the probed paths so the segment gets its answer without environment access.
- Do not bypass the gate — it is the mechanism that makes data-only rendering safe.
Example fix
// before: template assumes real FS
{{ if .HasParentFilePath ".git" }}...{{ end }}
// after: guard for data-only mode
{{ if and (not .Segments.EnvDisabled) (.HasParentFilePath ".git") }}...{{ end }} Defensive patterns
Strategy: try-catch
Validate before calling
// before probing, confirm you are not in data-only mode
if isDataOnlyRender {
return recordedValue // use captured data instead of env access
} Type guard
func envAccessAllowed(t *runtime.Terminal) bool {
// any gated probe erroring with errDataOnly means data-only mode
_, err := t.StatFile(".")
return !errors.Is(err, errDataOnly)
} Try / catch
path, err := term.HasParentFilePath(".git")
if err != nil {
// includes errDataOnly under WASM/recorded rendering
return nil // hide segment, fall back to recorded data
} Prevention
- Design segments so every probe has a recorded-data fallback.
- Test themes in the WASM/editor environment where env access is gated.
- Never bypass errDataOnly — it enforces the data-only guarantee.
When it happens
Trigger: Any call to the gated Terminal environment methods — StatFile, ResolveSymlink, RunCommandWithEnv, HTTPRequest, HasParentFilePath — while the terminal is configured in data-only mode (recorded data rendering).
Common situations: Rendering prompts from recorded/captured data in the browser/WASM playground; using the online theme editor; a segment that needs real environment probing is included in a data-only render.
Related errors
- the wasm build renders from data only and cannot make reques
- terminal width must be greater than zero
- failed to get shell config path: %w
- failed to get home directory
- render expects 4 arguments (configText, format, dataJSON, op
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/0b5b773f16fc3902.
Report an issue: GitHub.