FuelLabs/sway · error · anyhow::Error
Cannot find local repo at checkouts dir {}
Error message
Cannot find local repo at checkouts dir {} What it means
The same offline scan iterates read_dir of each candidate directory; any per-entry IO error (permission problem, entry disappearing mid-iteration, unreadable directory) is wrapped with this message and the underlying io::Error text.
Source
Thrown at forc-pkg/src/source/git/mod.rs:674
/// Search local checkouts directory and apply the given function. This is used for iterating over
/// possible options of a given package.
fn with_search_checkouts<F>(checkouts_dir: PathBuf, package_name: &str, mut f: F) -> Result<()>
where
F: FnMut(SourceIndex, PathBuf) -> Result<()>,
{
for entry in fs::read_dir(checkouts_dir)? {
let entry = entry?;
let folder_name = entry
.file_name()
.into_string()
.map_err(|_| anyhow!("invalid folder name"))?;
if folder_name.starts_with(package_name) {
// Search if the dir we are looking starts with the name of our package
for repo_dir in fs::read_dir(entry.path())? {
// Iterate over all dirs inside the `name-***` directory and try to open repo from
// each dirs inside this one
let repo_dir = repo_dir
.map_err(|e| anyhow!("Cannot find local repo at checkouts dir {}", e))?;
if repo_dir.file_type()?.is_dir() {
// Get the path of the current repo
let repo_dir_path = repo_dir.path();
// Get the index file from the found path
if let Ok(index_file) = fs::read_to_string(repo_dir_path.join(".forc_index")) {
let index = serde_json::from_str(&index_file)?;
f(index, repo_dir_path)?;
}
}
}
}
}
Ok(())
}
#[test]
fn test_source_git_pinned_parsing() {
let strings = [View on GitHub (pinned to 47e5e902fa)
Solutions
- Do not run concurrent forc builds sharing the same FORC_HOME, or ensure advisory path locks are respected
- Fix permissions on the printed directory and retry the build
- If the underlying error looks transient (network filesystem), retry the command once
Defensive patterns
Strategy: retry
Try / catch
let manifest = match pin_git_source(&source) {
Ok(m) => m,
Err(e) if e.to_string().contains("Cannot find local repo at checkouts dir") => {
// transient fs error while scanning: wait and retry once
std::thread::sleep(std::time::Duration::from_secs(2));
pin_git_source(&source)?
}
Err(e) => return Err(e),
}; Prevention
- Serialize builds that share the same FORC_HOME cache
- Keep the forc cache on local disk, not network mounts
- Fix permissions on cache dirs before builds
When it happens
Trigger: Filesystem-level problems while iterating ~/.forc/git/checkouts: entries removed concurrently by another forc process, permission changes mid-run, or failing/network-mounted disks.
Common situations: Two forc/build processes racing on the same FORC_HOME; permission edits during a build; NFS-mounted HOME flakiness.
Related errors
- invalid folder name
- Unable to fetch pkg {:?} from {:?} in offline mode
- failed to init repo at \"{}\": {}
- failed to write toml file: {}
- Cannot get parent dir of {:?}
AI-assisted analysis of FuelLabs/sway@47e5e902fa (2026-08-16).
Data as JSON: /api/errors/3a62d34dd3acd61e.
Report an issue: GitHub.