"zsh: command not found: fvm" 当我在 Android Studio 中打开我的 Flutter 项目时



我已经将这些添加到我的.zshrc文件中

export PATH="$PATH:`pwd`/.pub-cache/bin"
export PATH="$PATH:`pwd`/fvm/default/bin"
export PATH="$PATH:`pwd`/bin/cache/dart-sdk/bin"

当我在码头工作时,Flutter和fvm似乎工作得很好。但一旦我创建了一个新项目,并在Android Studio中使用终端,我就找不到命令了。

➜  flutter_fvm_stable echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/{Username}/flutter_fvm_stable/.pub-cache/bin:/Users/{Username}/flutter_fvm_stable/fvm/default/bin:/Users/{Username}/flutter_fvm_stable/bin/cache/dart-sdk/bin

➜  flutter_fvm_stable fvm doctor
zsh: command not found: fvm

我设法解决了颤振命令的这个问题:

➜  flutter_fvm_stable exexport PATH="/Users/{Username}/flutter/bin:$PATH" 
➜  flutter_fvm_stable flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-x64, locale en-BE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
...

但当我尝试使用fvm路径时,仍然一无所获。。

➜  flutter_fvm_stable exexport PATH="/Users/{Username}/fvm/default/bin:$PATH" 
➜  flutter_fvm_stable fvm doctor
zsh: command not found: fvm

我试过运行

export PATH="$PATH":"$HOME/.pub-cache/bin"

但后来我得到

Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):
export PATH="$PATH":"$HOME/.pub-cache/bin"

虽然我在我的.zshrc文件中已经有了这一行

export PATH="$PATH:`pwd`/.pub-cache/bin"

非常感谢你帮我!

虽然使用brew安装fvm是一种有效的方法,但它不是最初问题的直接解决方案。

下面的脚本修复了问题

echo 'export PATH="$PATH":"$HOME/fvm/default/bin"' >> ~/.zshrc && 
source ~/.zshrc

问题已经解决,因为我在Android Studio之外的终端中使用了此代码:

brew tap leoafarias/fvm
brew install fvm

我是从自制软件包管理器安装的,我必须添加这个路径

/opt/homebrew/bin/

到我的~/.zshrc档案

以便使fvm在任何终端中工作。

最新更新