{"record":{"id":"4c300d85794d696f","repo":"gleam-lang/gleam","slug":"packages-toml-serialization","errorCode":null,"errorMessage":"packages.toml serialization","messagePattern":"packages\\.toml serialization","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/dependencies.rs","lineNumber":712,"sourceCode":"        let path = paths.build_packages_toml();\n        if !path.exists() {\n            return Ok(Self {\n                packages: HashMap::new(),\n                git: HashMap::new(),\n            });\n        }\n        let toml = fs::read(&path)?;\n        toml::from_str(&toml).map_err(|error| Error::FileIo {\n            action: FileIoAction::Parse,\n            kind: FileKind::File,\n            path: path.clone(),\n            err: Some(error.to_string()),\n        })\n    }\n\n    pub fn write_to_disc(&self, paths: &ProjectPaths) -> Result<()> {\n        let path = paths.build_packages_toml();\n        let toml = toml::to_string(&self).expect(\"packages.toml serialization\");\n        fs::write(&path, &toml)\n    }\n\n    pub fn from_manifest(manifest: &Manifest) -> Self {\n        let packages = manifest\n            .packages\n            .iter()\n            .map(|p| (p.name.clone(), p.version.clone()))\n            .collect();\n        let git = manifest\n            .packages\n            .iter()\n            .filter_map(|p| match &p.source {\n                ManifestPackageSource::Git { commit, path, .. } => Some((\n                    p.name.clone(),\n                    GitState {\n                        commit: commit.clone(),\n                        path: path.clone(),","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/dependencies.rs#L694-L730","documentation":"write_to_disc serializes the resolved-packages map with toml::to_string and unwraps the result. Serialization only fails if the in-memory PackagesConfig contains values TOML cannot represent (e.g. mismatched value types injected by a manifest with unexpected shapes).","triggerScenarios":"Writing build/packages.toml after resolution when a package entry contains a type the TOML serializer rejects — e.g. a None/null in a spot TOML forbids, or a struct field type mismatch from a hand-edited or corrupt manifest.","commonSituations":"A corrupted or hand-edited manifest.toml producing unexpected package entries; a compiler bug after a manifest format change; filesystem write permission issues are NOT this error (that fails later at fs::write with a normal error).","solutions":["Delete the build directory (and regenerate manifest.toml with `gleam deps download`) to reset cached state","Check manifest.toml for hand-edited entries with unusual value types and restore valid syntax","Report to the Gleam repo with the manifest that triggers it — the panic indicates unvalidated data reaching the serializer","Upgrade the compiler, as serializer input validation may have been fixed"],"exampleFix":"// before: hand-edited manifest entry with wrong value type\n[dependencies.gleam_stdlib]\noversion = \"0.38\"\n// after\n[dependencies]\ngleam_stdlib = \">= 0.38.0 and < 2.0.0\"","handlingStrategy":"validation","validationCode":"// Before relying on cache, check manifest entries are well-formed TOML with valid versions\ntoml::from_str::<toml::Value>(&fs::read_to_string(\"manifest.toml\")?)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit manifest.toml; use `gleam add`/`gleam remove`","Commit a known-good manifest.toml and restore it if tooling panics","Regenerate build/packages.toml by deleting the build directory after crashes"],"tags":["toml","serialization","panic","filesystem"],"backgroundTag":"toml-serialization-failed","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}