问题描述
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"
非常感谢你帮助我!
解决方法
问题已解决,因为我在 Android Studio 之外的终端中使用了此代码:
brew tap leoafarias/fvm
brew install fvm