{"record":{"id":"6d5e752b775cb364","repo":"gitbutlerapp/gitbutler","slug":"repository-path-is-not-valid-utf-8","errorCode":null,"errorMessage":"Repository path is not valid UTF-8","messagePattern":"Repository path is not valid UTF-8","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":590,"sourceCode":"            .remote_default_name(gix::remote::Direction::Push)\n            .is_none()\n    {\n        anyhow::bail!(\n            \"Neither found push remote found in workspace nor unambiguously in the Git repository configuration.\"\n        )\n    };\n\n    Ok(true)\n}\n\n/// Creates a 'gb-local' remote pointing to this repository and creates tracking refs for the default branch.\nfn setup_local_remote(repo: &gix::Repository, out: &mut OutputChannel) -> anyhow::Result<String> {\n    let t = theme::get();\n    let repo_url = repo\n        .workdir()\n        .ok_or_else(|| anyhow::anyhow!(\"Repository has no working directory\"))?\n        .to_str()\n        .ok_or_else(|| anyhow::anyhow!(\"Repository path is not valid UTF-8\"))?;\n\n    if let Some(out) = out.for_human() {\n        writeln!(\n            out,\n            \"  {}\",\n            t.info\n                .paint(\"No push remote found, creating gb-local remote...\")\n        )?;\n    }\n\n    edit_repo_config(repo, gix::config::Source::Local, |config| {\n        let mut section = config.section_mut_or_create_new(\"remote\", Some(\"gb-local\".into()))?;\n        section.push(\"url\", repo_url)?;\n        Ok(())\n    })?;\n\n    // Figure out what local branch is probably the default target\n    let mut head_ref = repo.head()?;","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/setup.rs#L572-L608","documentation":"Thrown by `setup_local_remote` when the repository's working directory path cannot be converted to `&str` (it is not valid UTF-8). GitButler stores the remote URL as a UTF-8 string, so non-UTF-8 paths are rejected.","triggerScenarios":"Running setup in a repository located under a directory with non-UTF-8 bytes in its name (e.g. Latin-1 encoded filenames on Linux).","commonSituations":"Linux systems with legacy filesystem encodings; paths created by tools using raw bytes; mounts with unusual naming; ZIP extracts with mis-encoded names.","solutions":["Rename the repository directory (and parents) to ASCII/UTF-8-only names.","Move the clone to a path without special characters, e.g. `~/code/myrepo`.","Re-clone the repository into a UTF-8-safe location."],"exampleFix":"// before\n~/pr?jects/répo  (non-UTF-8 bytes)\n// after\nmv ~/projects/répo ~/projects/repo  # ensure valid UTF-8\nbut setup ~/projects/repo","handlingStrategy":"validation","validationCode":"const p = path.resolve(repoPath);\nif (!isUtf8(Buffer.from(p))) {\n  throw new Error(`Repo path must be valid UTF-8: ${p}`);\n}","typeGuard":"function isUtf8Path(p: string): boolean {\n  return Buffer.from(p, 'utf8').toString('utf8') === p;\n}","tryCatchPattern":"try {\n  await run(['but', 'setup', repoPath]);\n} catch (e) {\n  if (String(e).includes('not valid UTF-8')) {\n    console.error('Move/rename the repo to a UTF-8-only path.');\n  }\n  throw e;\n}","preventionTips":["Keep repo paths ASCII/UTF-8 only, especially on Linux.","Avoid extracting archives with legacy encodings into workspace directories.","Sanitize directory names created by automation before onboarding."],"tags":["filesystem","encoding","utf-8","cli"],"backgroundTag":"invalid-argument-format","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}