tw93/Pake · critical
Failed to parse tauri config
Error message
Failed to parse tauri config
What it means
get_pake_config also deserializes the embedded tauri.conf.json into tauri::Config with serde_json, panicking with this expect message if it fails. Because the file is compiled in, an invalid tauri.conf.json breaks the app before any window is created.
Solutions
- Validate tauri.conf.json against the Tauri v2 config schema (tauri CLI: `cargo tauri dev` reports the schema error).
- Fix JSON syntax or field types (check identifier, bundle, and windows sections).
- If the file was mutated by a build, restore it from git and re-run the pake CLI.
Example fix
// before (tauri.conf.json)
{ "identifier": "" }
// after
{ "identifier": "com.example.pakeapp" } Defensive patterns
Strategy: validation
Validate before calling
const conf = JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json'));
if (typeof conf.identifier !== 'string' || conf.identifier.length === 0) throw new Error('tauri.conf.json identifier missing'); Type guard
const looksLikeTauriConfig = (c) => typeof c === 'object' && c !== null && typeof c.identifier === 'string';
Try / catch
// dev-time guard
try { JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json', 'utf8')); } catch (e) { console.error('tauri.conf.json invalid:', e.message); process.exit(1); } Prevention
- Let the Tauri CLI manage tauri.conf.json edits; run `cargo tauri dev` to see schema errors immediately
- After Tauri version upgrades, re-validate the config against the new schema
- Keep tauri.conf.json churn from local builds restored before committing
When it happens
Trigger: tauri.conf.json (or .pake/tauri.conf.json under cli-build) contains JSON syntax errors or values violating Tauri v2's Config schema (e.g. bad bundle identifier, wrong types in windows options).
Common situations: Hand edits for custom icons/identifiers that break the schema; a Tauri major-version upgrade changing required fields; merge conflicts resolved incorrectly in tauri.conf.json.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse pake config
- about:blank must be a valid URL
- Invalid 'web' url ' ' in pake.json
- pake.json must define at least one window configuration
- url_type must be 'web' or 'local', got
AI-assisted analysis of tw93/Pake@c8fe8a3f1a (2026-09-20).
Data as JSON: /api/errors/7e389711e947489a.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/src/util.rs:18
use crate::app::config::PakeConfig;
use crate::app::window::MultiWindowState;
use std::env;
use std::path::{Path, PathBuf};
use tauri::{AppHandle, Config, Manager, WebviewWindow};
pub fn get_pake_config() -> (PakeConfig, Config) {
#[cfg(feature = "cli-build")]
let pake_config: PakeConfig = serde_json::from_str(include_str!("../.pake/pake.json"))
.expect("Failed to parse pake config");
#[cfg(not(feature = "cli-build"))]
let pake_config: PakeConfig =
serde_json::from_str(include_str!("../pake.json")).expect("Failed to parse pake config");
#[cfg(feature = "cli-build")]
let tauri_config: Config = serde_json::from_str(include_str!("../.pake/tauri.conf.json"))
.expect("Failed to parse tauri config");
#[cfg(not(feature = "cli-build"))]
let tauri_config: Config = serde_json::from_str(include_str!("../tauri.conf.json"))
.expect("Failed to parse tauri config");
(pake_config, tauri_config)
}
pub fn get_data_dir(app: &AppHandle, package_name: String) -> std::io::Result<PathBuf> {
let data_dir = app
.path()
.config_dir()
.map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::NotFound,
format!("Failed to resolve config dir: {err}"),
)
})?View on GitHub (pinned to c8fe8a3f1a)