使用`use`命令更改Flutter版本时出现Flutter FVM错误

4

我想使用flutter fvm版本管理,但在尝试使用新版本时出现了这个错误。那个配置文件会自动生成吗?如何启用权限?

D:\dev_projects\myapp>fvm list
Cache Directory:  C:\Users\user\fvm\versions

2.2.3
1.22.5 (active)

D:\dev_projects\myapp>fvm use 2.2.3 --verbose
[     0.073s] FileSystemException: Cannot open file, path = 'C:\Users\user\fvm\.settings' (OS Error: The system cannot find the file specified., errno = 2)
[     0.082s] FileSystemException: Cannot open file, path = 'C:\Users\user\fvm\.settings' (OS Error: The system cannot find the file specified., errno = 2)
[     0.082s] FileSystemException: Cannot open file, path = 'C:\Users\user\fvm\.settings' (OS Error: The system cannot find the file specified., errno = 2)
[     0.084s] Version: 2.2.3 - already installed.
[     0.090s] FileSystemException: Cannot open file, path = 'C:\Users\user\fvm\.settings' (OS Error: The system cannot find the file specified., errno = 2)
[     0.097s] FileSystemException: Cannot create link to target 'C:\Users\user\fvm\versions\1.22.5', path = 'D:\dev_projects\myapp\.fvm\flutter_sdk' (OS Error: A required privilege is not held by the client.
, errno = 1314)
[     0.098s] Usage Exception: Seems you don't have the required permissions on C:\Users\user\fvm On Windows FVM requires to run as an administrator or turn on developer mode: 

更新:

D:\dev_projects\myapp>fvm doctor
    
    FVM Version: 2.2.3
    ___________________________________________________
    
    FVM config found:
    ___________________________________________________
    
    Project: myapp
    Directory: D:\dev_projects\myapp
    Version: 1.22.5
    Project Flavor: None selected
    ___________________________________________________
    
    Version is currently cached locally.
    
    Cache Path: C:\Users\user\fvm\versions\1.22.5
    Channel: false
    SDK Version: 1.22.5
    
    IDE Links
    VSCode: .fvm/flutter_sdk
    Android Studio: D:\dev_projects\myapp\.fvm\flutter_sdk
    
    
    Configured env paths:
    ___________________________________________________
    
    Flutter:
    D:\dev\flutter\bin\flutter.bat
    
    Dart:
    D:\dev\flutter\bin\dart.bat
    
    FVM_HOME:
    not set

1
只需使用 fvm use 2.2.3 - John Joe
1
fvm use 旨在用于 Flutter 项目中。看起来您正在从 fvm 安装文件夹中使用它。如果您想要全局使用某个版本的 Flutter 并随时调用它,可以使用 fvm global 2.2.3 - Martyns
@Martyns,它仍然有相同的错误。你说的从fvm安装文件夹中使用它是什么意思?顺便说一下,我正在myapp flutter项目内使用vscode终端。我更新了问题,包括fvm doctor。 - unice
@unice 对不起,你是对的。我误读了日志。 - Martyns
3个回答

12

对我来说,这是因为我复制了一个Flutter项目文件夹。我删除了“.fvm”文件夹并使用“fvm use”命令,它就可以工作了。


1

根据日志建议,我通过开启开发者模式来解决了这个问题。前往设置,搜索开发者设置并从那里启用它。现在重新启动IDE并重试。


-1

我不知道这是否是正确的方法,但我通过以管理员身份运行vscode来解决了它。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接