{"record":{"id":"85a21a32b4994369","repo":"wasmerio/wasmer","slug":"config-from-file-e","errorCode":null,"errorMessage":"config from file: {e}","messagePattern":"config from file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/auth/login/mod.rs","lineNumber":210,"sourceCode":"        } else {\n            // switch between two methods of getting the token.\n            // start two async processes, 10 minute timeout and get token from browser. Whichever finishes first, use that.\n            let timeout_future = tokio::time::sleep(Duration::from_secs(60 * 10));\n            tokio::select! {\n             _ = timeout_future => {\n                     Ok(AuthorizationState::TimedOut)\n                 },\n                 token = self.get_token_from_browser(&client) => {\n                    token\n                 }\n            }\n        }\n    }\n\n    async fn login_and_save(&self, env: &WasmerEnv, token: String) -> anyhow::Result<String> {\n        let registry = env.registry_endpoint()?;\n        let mut config = WasmerConfig::from_file(env.dir())\n            .map_err(|e| anyhow::anyhow!(\"config from file: {e}\"))?;\n        config\n            .registry\n            .set_current_registry(registry.as_ref())\n            .await;\n        config.registry.set_login_token_for_registry(\n            &config.registry.get_current_registry(),\n            &token,\n            UpdateRegistry::Update,\n        );\n        let path = WasmerConfig::get_file_location(env.dir());\n        config.save(path)?;\n\n        // This will automatically read the config again, picking up the new edits.\n        let client = env.client()?;\n\n        wasmer_backend_api::query::current_user(&client)\n            .await?\n            .map(|v| v.username)","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/auth/login/mod.rs#L192-L228","documentation":"`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.","triggerScenarios":"`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.","commonSituations":"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.","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`."],"exampleFix":"// before\n$ wasmer login $TOKEN\n// error: config from file: failed to parse ~/.wasmer/wasmer.toml\n// after\n$ mv ~/.wasmer/wasmer.toml ~/.wasmer/wasmer.toml.bak\n$ wasmer login $TOKEN  # regenerates a fresh valid config","handlingStrategy":"validation","validationCode":"// validate the config file parses before running login\nwasmer config 2>/dev/null || { \n  echo \"wasmer.toml is invalid; restore or remove ~/.wasmer/wasmer.toml\"; \n}\n# or in Rust: WasmerConfig::from_file(dir).is_ok() check up front","typeGuard":null,"tryCatchPattern":"match WasmerConfig::from_file(env.dir()) {\n    Ok(cfg) => cfg,\n    Err(e) => {\n        eprintln!(\"config unreadable ({e}); backing it up and starting fresh\");\n        std::fs::rename(env.dir().join(\"wasmer.toml\"), env.dir().join(\"wasmer.toml.bak\"))?;\n        WasmerConfig::from_file(env.dir()).unwrap_or_default()\n    }\n}","preventionTips":["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."],"tags":["auth","configuration","wasmer-toml"],"backgroundTag":"config-parse-failed","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}