browsh-org/browsh · critical
Config file error: %s
Error message
Config file error: %s
What it means
`loadConfig` first loads an embedded sample config (so new default fields exist) and then merges the user's own .toml over it via `viper.MergeInConfig`. Either read failing causes a panic with `Config file error: <err>`. The first panic (sample config) is effectively an internal bug; the second means the user's config file is missing, unreadable, or malformed TOML.
Source
Thrown at interfacer/src/browsh/config.go:91
}
func setDefaults() {
// Temporary experimental configurable keybindings
viper.SetDefault("tty.keys.next-tab", []string{"\u001c", "28", "2"})
}
func loadConfig() {
dir := getConfigDir()
fullPath := filepath.Join(dir, configFilename)
slog.Info("Looking in " + fullPath + " for config.")
viper.SetConfigType("toml")
viper.SetConfigName(strings.Trim(configFilename, ".toml"))
viper.AddConfigPath(dir)
viper.AddConfigPath(".")
setDefaults()
// First load the sample config in case the user hasn't updated any new fields
if err := viper.ReadConfig(bytes.NewBuffer([]byte(configSample))); err != nil {
panic(fmt.Errorf("Config file error: %s \n", err))
}
// Then load the users own config file, overwriting the sample config
if err := viper.MergeInConfig(); err != nil {
panic(fmt.Errorf("Config file error: %s \n", err))
}
viper.BindPFlags(pflag.CommandLine)
}
View on GitHub (pinned to 499ef386d4)
Solutions
- Run the TOML through a validator/linter and fix the syntax errors reported in the panic message.
- Confirm the file exists and is readable at the resolved location (cwd or the configured dir) and that its name survives the `.toml`-character trimming (stick to a plain `browsh.toml`).
- Start with the sample config from the repo, then incrementally add your own settings.
- Check file permissions (`chmod u+r config.toml`) if the file exists but can't be read.
Example fix
// before (config.toml, invalid TOML) firefox] path = /usr/bin/firefox // after [firefox] path = "/usr/bin/firefox"
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
const configFile = 'browsh.toml';
if (!fs.existsSync(configFile)) throw new Error(`Config file ${configFile} not found`);
const toml = require('@iarna/toml');
toml.parse(fs.readFileSync(configFile, 'utf8')); // throws on invalid TOML Try / catch
try {
startBrowsh();
} catch (e) {
if (/Config file error/.test(e.message)) {
console.error('Fix or provide browsh config (.toml):', e.message);
} else { throw e; }
} Prevention
- Validate config TOML with a linter before launching browsh.
- Keep the config filename simple (e.g. browsh.toml) — the code trims characters in the set '.tml o' from the name.
- Start from the repo's sample config and change incrementally.
- Check file permissions when the config exists but is unreadable.
When it happens
Trigger: `Initialise` -> `loadConfig`; `viper.MergeInConfig()` fails because the config file derived from `configFilename`/the `-config` flag doesn't exist, has no read permission, or contains invalid TOML (the sample-config panic only occurs if the embedded sample itself fails to parse).
Common situations: Wrong `-config` filename (note `strings.Trim(configFilename, ".toml")` strips any leading/trailing chars in the set '.tml o', so unusual extensions/names break lookup); hand-edited TOML with syntax errors (missing quotes/brackets); unreadable permissions; running from a directory without the expected config file.
Related errors
- A headless Firefox is already running
- Firefox binary not found:
- There appears to already be an existing Web Extension connec
- Failed to connect to Firefox's Marionette within 30 seconds
- Error starting websocket server: %w
AI-assisted analysis of browsh-org/browsh@499ef386d4 (2026-09-02).
Data as JSON: /api/errors/1216aa0e5b24dca2.
Report an issue: GitHub.