Windows下执行repo init命令出现文件句柄限制失败警告求助
Hey there, let's tackle that repo init warning: failed to restrict file handles message you're seeing when running repo init -u git@foo.bar -b dev on Windows. This is usually a compatibility quirk between repo's Linux-origin scripts and Windows' file system permissions—not necessarily a sign of corrupted files, though we'll cover checks for that too. Here are actionable fixes to try, ordered from simplest to most thorough:
Run your terminal as Administrator
Windows' default user permissions might block repo from adjusting file handle restrictions. Right-click your terminal (CMD, PowerShell, or Git Bash) and select "Run as administrator", then re-execute therepo initcommand.Update Git for Windows
Older Git versions can cause compatibility issues with repo. Open Git Bash and rungit --versionto check your current version. If it's below 2.30.x, download and install the latest version of Git for Windows, then retry the repo command.Disable file handle restriction via environment variable
Repo uses a file system notification feature that can misbehave on Windows. You can disable it temporarily or permanently:- Temporary fix (per session):
- For CMD: Run
set REPO_DISABLE_FSNOTIFY=1before yourrepo initcommand. - For PowerShell: Run
$env:REPO_DISABLE_FSNOTIFY=1beforerepo init.
- For CMD: Run
- Permanent fix: Add a system environment variable named
REPO_DISABLE_FSNOTIFYwith a value of1, then restart your terminal and try again.
- Temporary fix (per session):
Clean up existing repo cache and reinitialize
Partial or corrupted initialization files might be causing the warning. Delete the.repofolder in your current working directory (make sure to back up any important files inside first), then runrepo init -u git@foo.bar -b devagain from scratch.Verify your SSH connection to the remote repo
Since you're using an SSH URL (git@foo.bar), ensure your SSH keys are properly configured to connect to the remote server. Test the connection first withssh -T git@foo.bar—if you get an error, resolve the SSH authentication issue before retrying repo init.
If the warning persists but the repo initialization completes successfully, it's often a harmless compatibility message. For more reliable repo performance on Windows, consider using Windows Subsystem for Linux (WSL)—it provides a Linux-like environment where repo runs without these file system quirks.
内容的提问来源于stack exchange,提问作者Ci Kai

