{"record":{"id":"6cea0d9cff4e502f","repo":"gleam-lang/gleam","slug":"output-should-be-utf-8","errorCode":null,"errorMessage":"Output should be UTF-8","messagePattern":"Output should be UTF-8","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/dependencies.rs","lineNumber":1133,"sourceCode":"\n/// Map an IO error from spawning `git` onto the appropriate `Error`.\nfn git_io_error(error: std::io::Error) -> Error {\n    match error.kind() {\n        ErrorKind::NotFound => Error::ShellProgramNotFound {\n            program: \"git\".into(),\n            os: fs::get_os(),\n        },\n        other => Error::ShellCommand {\n            program: \"git\".into(),\n            reason: ShellCommandFailureReason::IoError(other),\n        },\n    }\n}\n\n/// Parse the trimmed UTF-8 stdout of a `git` command.\nfn git_stdout(output: std::process::Output) -> EcoString {\n    String::from_utf8(output.stdout)\n        .expect(\"Output should be UTF-8\")\n        .trim()\n        .into()\n}\n\nfn git_repo_dir_name(repo: &str) -> String {\n    let name = repo\n        .trim_end_matches('/')\n        .trim_end_matches(\".git\")\n        .rsplit(['/', ':', '\\\\'])\n        .next()\n        .filter(|name| !name.is_empty())\n        .unwrap_or(\"repo\");\n    let hash = xxhash_rust::xxh3::xxh3_64(repo.as_bytes());\n    format!(\"{name}-{hash:016x}\")\n}\n\nfn git_staging_path(project_paths: &ProjectPaths, repo: &str, package_name: &str) -> Utf8PathBuf {\n    project_paths.build_git_repo(&format!(","sourceCodeStart":1115,"sourceCodeEnd":1151,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/dependencies.rs#L1115-L1151","documentation":"A guard in the git-integration error mapping of the CLI. `git_stdout` converts raw `git` command stdout bytes into an EcoString and this message fires when `String::from_utf8` fails, i.e. `git` emitted output that is not valid UTF-8. The input at fault is the captured stdout of a spawned `git` process (e.g. a repository path, branch name, or tag containing non-UTF-8 bytes), typically due to unusual filenames or locale settings on the user's system.","triggerScenarios":"A `git` command run during dependency fetching (e.g. resolving a git dependency's refs/HEAD) whose stdout contains non-UTF-8 bytes, such as repo directory names, ref names, or commit messages in a non-UTF-8 locale.","commonSituations":"Git dependencies whose local path or tag names contain non-UTF-8 characters; machines with legacy locales (e.g. Latin-1 filesystem encoding); git configuration that prints localized output with non-UTF-8 characters.","solutions":["Rename the offending git repository, directory, or tag/branch to use only UTF-8/ASCII characters","Set a UTF-8 locale (LANG/LC_ALL=C.UTF-8) so git output is UTF-8 encoded","Check git config (core.quotepath=false) and avoid non-UTF-8 ref names in the dependency repo","Report to the Gleam repo — decoding should use from_utf8_lossy instead of expect"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Ensure UTF-8 environment before running git-dependent commands\nexport LANG=C.UTF-8\nexport LC_ALL=C.UTF-8","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep repository names, tags, and branch names ASCII/UTF-8 only","Set a UTF-8 locale system-wide, especially in CI and containers","Avoid git dependencies whose refs contain non-UTF-8 characters"],"tags":["git","utf8","encoding","panic"],"backgroundTag":"git-command-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"}