簡體   English   中英

“zsh: command not found: fvm” 當我在 Android Studio 中打開我的 Flutter 項目時

[英]"zsh: command not found: fvm" When I open my Flutter project in Android Studio

我已經將這些添加到 my.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 命令解決了這個問題:

➜  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

我已經從自制 package 管理器安裝,我必須添加這個路徑

/opt/homebrew/bin/

到我的 ~/.zshrc 個人資料

為了使 fvm 在任何終端上工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM