babalae/better-genshin-impact · error · Exception
仓库中不存在路径: {sourcePath}
Error message
仓库中不存在路径: {sourcePath} What it means
Thrown in the file-system fallback branch of CheckoutPath (when the repo is NOT a Git repo, i.e., a plain directory): neither Directory.Exists(scriptPath) nor File.Exists(scriptPath) matched, so the requested sourcePath does not exist on disk under repoPath.
Source
Thrown at BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs:1669
if (Directory.Exists(scriptPath))
{
// 复制目录
CopyDirectory(scriptPath, destPath);
}
else if (File.Exists(scriptPath))
{
// 复制文件
var dir = Path.GetDirectoryName(destPath);
if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
File.Copy(scriptPath, destPath, true);
}
else
{
throw new Exception($"仓库中不存在路径: {sourcePath}");
}
}
}
/// <summary>
/// 递归检出树对象
/// </summary>
private void CheckoutTree(Tree tree, string destPath, string currentPath)
{
if (!Directory.Exists(destPath))
{
Directory.CreateDirectory(destPath);
}
foreach (var entry in tree)
{
var entryDestPath = Path.Combine(destPath, entry.Name);
var entrySourcePath = $"{currentPath}/{entry.Name}";View on GitHub (pinned to a7cb36712d)
Solutions
- Verify the file-based repo is fully extracted: list repoPath and confirm the sourcePath exists before calling CheckoutPath.
- Normalize sourcePath separators and casing to match the OS before the File/Directory.Exists checks.
- Re-download or re-import the script repo zip if files are missing.
- Make the Git branch and file branch consistent — both should throw or both return silently on missing paths.
Example fix
// before
else
{
throw new Exception($"仓库中不存在路径: {sourcePath}");
}
// after (include resolved path)
else
{
throw new FileNotFoundException(
$"仓库中不存在路径: {sourcePath}(已解析为 {scriptPath})", scriptPath);
} Defensive patterns
Strategy: validation
Validate before calling
// For file-based repos, verify before checkout
var resolved = Path.Combine(repoPath, sourcePath);
if (!File.Exists(resolved) && !Directory.Exists(resolved))
throw new FileNotFoundException($"仓库中不存在路径: {sourcePath}", resolved); Try / catch
catch (FileNotFoundException ex)
{
_logger.LogWarning(ex, "文件仓库缺少路径,跳过: {Path}", sourcePath);
// optionally skip vs. fail depending on manifest strictness
} Prevention
- Normalize separators/casing before File/Directory.Exists checks.
- Re-extract the zip repo if files are unexpectedly missing.
- Make the Git and file branches behave consistently on missing paths.
When it happens
Trigger: CheckoutPath called with a file-based repo (IsGitRepository returns false) and sourcePath that resolves to a path under repoPath which is neither a file nor a directory. This is the file-copy branch; the Git branch returns silently on missing paths, but the file branch throws.
Common situations: A manifest references a file that was deleted from the repo; extraction of a zip repo was incomplete; the sourcePath uses separators or casing that don't match the on-disk layout; the repo directory was partially cleaned up.
Related errors
- 路径中间部分不是目录: {string.Join("/", pathParts.Take(i + 1))}
- 本地仓库缺少 repo.json
- 未找到 repo.json 文件,不是有效的脚本仓库压缩包。
- 文件路径 '{path}' 包含非法字符
- 要启动的程序不存在。
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/aff83e1cb21c1021.
Report an issue: GitHub.