wasmerio/wasmer · error
config from file: {e}
Error message
config from file: {e} What it means
`login_and_save` loads the existing `wasmer.toml` config via `WasmerConfig::from_file(env.dir())` so it can attach the new login token to the current registry. Any failure reading or parsing that config file is re-raised as `config from file: {e}`. The login itself succeeded; persisting it failed because the local config is unreadable or malformed.
Source
Thrown at lib/cli/src/commands/auth/login/mod.rs:210
} else {
// switch between two methods of getting the token.
// start two async processes, 10 minute timeout and get token from browser. Whichever finishes first, use that.
let timeout_future = tokio::time::sleep(Duration::from_secs(60 * 10));
tokio::select! {
_ = timeout_future => {
Ok(AuthorizationState::TimedOut)
},
token = self.get_token_from_browser(&client) => {
token
}
}
}
}
async fn login_and_save(&self, env: &WasmerEnv, token: String) -> anyhow::Result<String> {
let registry = env.registry_endpoint()?;
let mut config = WasmerConfig::from_file(env.dir())
.map_err(|e| anyhow::anyhow!("config from file: {e}"))?;
config
.registry
.set_current_registry(registry.as_ref())
.await;
config.registry.set_login_token_for_registry(
&config.registry.get_current_registry(),
&token,
UpdateRegistry::Update,
);
let path = WasmerConfig::get_file_location(env.dir());
config.save(path)?;
// This will automatically read the config again, picking up the new edits.
let client = env.client()?;
wasmer_backend_api::query::current_user(&client)
.await?
.map(|v| v.username)View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Inspect the inner `{e}` detail and fix or remove the malformed wasmer.toml (delete it and log in again to regenerate).
- Check permissions on $WASMER_DIR (~/.wasmer by default).
- Verify WASMER_DIR env var points at the intended directory.
- Back up then `rm ~/.wasmer/wasmer.toml` and rerun `wasmer login`.
Example fix
// before $ wasmer login $TOKEN // error: config from file: failed to parse ~/.wasmer/wasmer.toml // after $ mv ~/.wasmer/wasmer.toml ~/.wasmer/wasmer.toml.bak $ wasmer login $TOKEN # regenerates a fresh valid config
Defensive patterns
Strategy: validation
Validate before calling
// validate the config file parses before running login
wasmer config 2>/dev/null || {
echo "wasmer.toml is invalid; restore or remove ~/.wasmer/wasmer.toml";
}
# or in Rust: WasmerConfig::from_file(dir).is_ok() check up front Try / catch
match WasmerConfig::from_file(env.dir()) {
Ok(cfg) => cfg,
Err(e) => {
eprintln!("config unreadable ({e}); backing it up and starting fresh");
std::fs::rename(env.dir().join("wasmer.toml"), env.dir().join("wasmer.toml.bak"))?;
WasmerConfig::from_file(env.dir()).unwrap_or_default()
}
} Prevention
- Don't hand-edit wasmer.toml; use `wasmer config` subcommands.
- Keep ~/.wasmer writable by your user.
- If login suddenly fails, back up and delete wasmer.toml to regenerate it cleanly.
When it happens
Trigger: `wasmer login <token>` → `run_async` → `login_and_save` → `WasmerConfig::from_file` errors due to a corrupt/invalid `~/.wasmer/wasmer.toml` or an unreadable wasmer dir.
Common situations: Manually edited wasmer.toml with schema/typo errors; permission problems on ~/.wasmer; partial file writes from a crashed previous run; WASMER_DIR pointing at a directory that is not a valid config location.
Related errors
- No registry not specified!
- Stack size must be 1024-bit aligned
- Headless is not a valid runtime to instantiate directly
- Could not parse app.yaml: {err:?}
- The backend did not return any nonce to auth the login!
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/85a21a32b4994369.
Report an issue: GitHub.