You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FVM安装Flutter版本失败:Git克隆报错求助

解决FVM安装Flutter版本时的Git克隆失败问题

问题详情

已完成以下操作:

  • 通过dart pub global activate fvm激活FVM包,将Pub/Cache/bin添加到系统路径
  • 正确安装Flutter、Dart和Git

执行fvm install stable或fvm install 3.13.0时,报错如下:

fvm install stable
Creating local mirror...
 Counting objects:    [██████████████████████████████████████████████████] 100%
 Compressing objects: [██████████████████████████████████████████████████] 100%
 Receiving objects:   [██................................................] 4%
✓ Clone complete
✗ Failed to ensure stable is cached.

Exception: Git clone failed

Please run command with  --verbose if you want more information

添加--verbose参数后的详细日志:

fvm install stable --verbose

Argument information:
  Top level options:
  - verbose: true

Command: install

Creating local mirror...
 Counting objects:    [██████████████████████████████████████████████████] 100%
 Compressing objects: [██████████████████████████████████████████████████] 100%
 Receiving objects:   [██................................................] 4%
✓ Clone complete
✗ Failed to ensure stable is cached.

Exception: Git clone failed

package:fvm/src/utils/parsers/git_clone_update_printer.dart 80:5                      runGitCloneUpdate
package:fvm/src/services/flutter_service.dart 146:7                                   FlutterService.updateLocalMirror
package:fvm/src/workflows/ensure_cache.workflow.dart 73:7                             ensureCacheWorkflow
package:fvm/src/commands/install_command.dart 66:26                                   InstallCommand.run
package:args/command_runner.dart 212:13                                               CommandRunner.runCommand
package:fvm/src/runner.dart 233:18                                                    FvmCommandRunner.runCommand
package:fvm/src/runner.dart 115:24                                                    FvmCommandRunner.run
package:scope/src/scope.dart 151:12                                                   Scope.run
C:\Users\Samama\AppData\Local\Pub\Cache\hosted\pub.dev\fvm-3.0.11\bin\main.dart 13:5  main

本地FVM文件夹结构:

ls -lha
total 0
drwxrwxrwx 1 glitchlover glitchlover 512 Feb 28 17:16 .
drwxrwxrwx 1 glitchlover glitchlover 512 Feb 26 20:39 ..
drwxrwxrwx 1 glitchlover glitchlover 512 Feb 26 21:58 cache.git
drwxrwxrwx 1 glitchlover glitchlover 512 Feb 28 17:17 default

环境信息:

  • Windows 11
  • FVM版本3.0.11
  • FVM Doctor提示无法解析符号链接
  • Flutter Doctor显示当前Flutter处于未知分支,上游仓库非标准远程

解决方案

1. 清理FVM本地缓存并重新初始化

  • 删除FVM的缓存目录,默认路径为C:\Users\<你的用户名>\fvm
  • 重新执行初始化命令:
fvm config cache-path "C:\Users\<你的用户名>\fvm"

2. 手动修复Git克隆问题

直接通过Git手动克隆Flutter仓库到FVM缓存目录,再让FVM识别:

# 进入FVM缓存的git目录
cd C:\Users\<你的用户名>\fvm\cache.git
# 添加Flutter官方远程仓库
git remote add upstream https://github.com/flutter/flutter.git
# 拉取最新代码
git fetch upstream
# 切换到stable分支
git checkout stable
# 拉取子模块
git submodule update --init --recursive

完成后再执行fvm install stable

3. 修复符号链接权限问题(Windows)

  • 以管理员身份打开命令提示符或PowerShell
  • 执行命令开启开发者模式(解决符号链接权限):
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
  • 重启电脑后重新尝试FVM安装命令

4. 切换FVM的Flutter源为国内镜像(如果网络问题导致)

设置FVM使用国内镜像仓库:

fvm config git-url https://mirrors.tuna.tsinghua.edu.cn/git/flutter.git

之后再执行fvm install stable

5. 更新FVM到最新版本

dart pub global activate fvm

更新后重试安装命令


内容的提问来源于stack exchange,提问作者Shamama Sami

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 21:37:39