Open husainazkas opened 4 months ago
@husainazkas, after you use
the version the terminal should indicate that the PATH has changed. Like this video. Can you review and make sure that this is happening?
https://github.com/leoafarias/fvm/assets/435833/d284b8f8-2bff-404e-bde6-34c8c7b7fc3c
Sorry there is a missing step on reproduce. Actually I always make myself to very clearly sure that any changes affected by reopen terminal & vscode directly, ofcourse when vscode reopened it will continue last terminal then I always kill & open new terminal. But no luck, it still read global version because of PATH on my .zshrc
referred to ~/fvm/default/bin/flutter
.
And also if you look at my fvm doctor
you can see the flutter version and dart version is not match, I know I have to make another github issue but I'll do it later
@husainazkas interesting, there is a settings flag called addSdkToTerminalPath. Can you also confirm that this is set to true?
ofcourse it's set to true
any updates? @leoafarias
I was not able to replicate.
Can you do "which flutter" on the vscode terminal and send the output here?
I think I found possibility reason why this bug happened.
Previously, I have set below env to my .zshrc
:
export PATH=$HOME/fvm/default/bin:$PATH
It means global version has been set on user-level env. So If I open vscode that use different flutter version and call flutter
instead of fvm flutter
it will refer to my .zshrc config and show wrong version, not as described in 3.0.0 release note.
But if that flutter global version is not set on .zshrc, I can call flutter
in a flutter project with correct version sdk.
Ofcouse I cannot call flutter
outside flutter project because zsh will not know that command. To fix this we can set aliases through .zshrc like this:
alias flutter="fvm flutter"
alias dart="fvm dart"
My analysis still not fix whole problem, it leaves one more problem. The problem is vscode extension still have weird env config (Idk why) when you call command palette Run flutter doctor
, the output will have warning flutter path like this:
[flutter] flutter doctor -v
[!] Flutter (Channel stable, 3.13.9, on macOS 14.3.1 23D60 darwin-x64, locale en-ID)
• Flutter version 3.13.9 on channel stable at /Users/husainazkas/fvm/versions/3.13.9
! Warning: `flutter` on your path resolves to /Users/husainazkas/fvm/versions/stable/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/husainazkas/fvm/versions/3.13.9. Consider adding /Users/husainazkas/fvm/versions/3.13.9/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/husainazkas/fvm/versions/stable/bin/dart, which is not inside your current Flutter SDK checkout at /Users/husainazkas/fvm/versions/3.13.9. Consider adding /Users/husainazkas/fvm/versions/3.13.9/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d211f42860 (4 months ago), 2023-10-25 13:42:25 -0700
• Engine revision 0545f8705d
• Dart version 3.1.5
• DevTools version 2.25.0
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/husainazkas/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/husainazkas/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = /Applications/Android Studio.app
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
[✓] VS Code (version 1.86.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.82.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 14.3.1 23D60 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
! Error: Browsing on the local area network for My iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
exit code 0
I was not able to replicate.
Can you do "which flutter" on the vscode terminal and send the output here?
After my fix above, it has succeed show correct output (not sure but at least correct version):
> which flutter
/Users/husainazkas/fvm/versions/3.13.9/bin//flutter
I would suggest against doing this. This is a bit weird as I believe dart code extension adds priority over the PATH. But will confirm.
One last questions do you have the env FLUTTER_ROOT configured anywhere?
nope
I have encounter this issue also with FVM 3.1.4. Interestingly, I am able to setup one project without problem, but the second project I setup got this issue.
I have encounter this issue also with FVM 3.1.4. Interestingly, I am able to setup one project without problem, but the second project I setup got this issue.
I got it fix by reinstall the VS Code's Flutter & Dart extension
brew uninstall flutter
nano ~/.zshrc
Remove all flutter variables then add this (export all flutter versions to the path)
# FLUTTER
for dir in $HOME/fvm/versions/*; do
if [ -d "$dir" ]; then
export PATH="$dir/bin:$PATH"
fi
done
export PATH="$HOME/fvm/default/bin:$PATH"
export PATH="$HOME/.pub-cache/bin:$PATH"
alias flutter="fvm flutter"
alias dart="fvm dart"
Kill the terminal, and Vscode then open them again
Same issue here. Sometimes I just simply change SDKs to another one or change to another project and then for no reason flutter doctor and fvm flutter doctor will stop giving the same output.
The vscode integration needs to happen within the vscode terminal for the behavior to be correct.
When running a project-configured flutter sdk outside of vscode, you still have to proxy or create an alias that points to the project symlink.
I'm doing everything through the vscode terminal and fvm though so no weird actions on my part there. edit: Did a whole flutter and fvm clean install and the problem persists.
I faced the same issue. I added fvm to the beginning of PATH like this export PATH=$HOME/fvm/default/bin:$PATH
in my .zshrc
. Changed it to be appended to the end like this: export PATH=$PATH:$HOME/fvm/default/bin
. And then it worked.
I also needed to set
"dart.addSdkToTerminalPath": true
Describe the bug I've read your release changelog for this version which at first point it says fvm will automatically configure VSCode to use the correct Flutter SDK version. So I just need to type
flutter
instead offvm flutter
. The problem is it's not like you describe.To Reproduce Steps to reproduce the behavior:
fvm use 3.13.9
flutter --version
, you will see Flutter SDK version from globalfvm flutter --version
, you will see Flutter SDK version from current projectExpected behavior As you describe in changelog, I hope whatever version I use in different project will use correct SDK version, except has not configured with specific version
Logs
Command: global
✔ Select a version: · stable
Default in path: true Cached version in path: false Pinned version in path: false
flutterInPath: /Users/husainazkas/fvm/default/bin ctx.globalCacheBinPath: /Users/husainazkas/fvm/default/bin cacheVersion.binPath: /Users/husainazkas/fvm/versions/stable/bin pinnedCacheVersion?.binPath: /Users/husainazkas/fvm/versions/3.13.9/bin
Flutter SDK: Channel: Stable is now global
Show
flutter
version at current projectShow
fvm flutter
version at current projectRun
fvm doctor
at current projectFVM Doctor:
Project: ┌─────────────────────────────┬────────────────────────────────────────────────────────────┐ │ Project │ flutter_project │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Directory │ /Users/husainazkas/path/to/project/flutter_project │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Active Flavor │ None │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Is Flutter Project │ Yes │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Dart Tool Generator Version │ 3.1.5 │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Dart tool version │ 3.13.9 │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ .gitignore Present │ Yes │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Config Present │ Yes │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Pinned Version │ 3.13.9 │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Config path │ .fvmrc │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Local cache dir │ .fvm/versions │ ├─────────────────────────────┼────────────────────────────────────────────────────────────┤ │ Version symlink │ .fvm/versions/3.13.9 │ └─────────────────────────────┴────────────────────────────────────────────────────────────┘
IDEs: ┌────────────────────────────────┬────────────────────────────────────────┐ │ IDEs │ Value │ ├────────────────────────────────┼────────────────────────────────────────┤ │ VSCode │ │ ├────────────────────────────────┼────────────────────────────────────────┤ │ dart.flutterSdkPath │ .fvm/versions/3.13.9 │ ├────────────────────────────────┼────────────────────────────────────────┤ │ Matches pinned version: │ true │ ├────────────────────────────────┼────────────────────────────────────────┤ │ IntelliJ (Android Studio, ...) │ │ ├────────────────────────────────┼────────────────────────────────────────┤ │ flutter.sdk │ /Users/husainazkas/fvm/versions/3.13.9 │ ├────────────────────────────────┼────────────────────────────────────────┤ │ Matches pinned version: │ true │ ├────────────────────────────────┼────────────────────────────────────────┤ │ IntelliJ (Android Studio, ...) │ No .idea folder found │ └────────────────────────────────┴────────────────────────────────────────┘
Environment: ┌───────────────────────┬────────────────────────────────────────────┐ │ Environment Variables │ Value │ ├───────────────────────┼────────────────────────────────────────────┤ │ Flutter PATH │ /Users/husainazkas/fvm/default/bin/flutter │ ├───────────────────────┼────────────────────────────────────────────┤ │ Dart PATH │ /usr/local/bin/dart │ ├───────────────────────┼────────────────────────────────────────────┤ │ FVM_CACHE_PATH │ N/A │ ├───────────────────────┼────────────────────────────────────────────┤ │ FVM_GIT_CACHE │ N/A │ ├───────────────────────┼────────────────────────────────────────────┤ │ FVM_GIT_CACHE_PATH │ N/A │ ├───────────────────────┼────────────────────────────────────────────┤ │ FVM_FLUTTER_URL │ N/A │ ├───────────────────────┼────────────────────────────────────────────┤ │ Flutter PATH │ /Users/husainazkas/fvm/default/bin/flutter │ ├───────────────────────┼────────────────────────────────────────────┤ │ Dart PATH │ /usr/local/bin/dart │ └───────────────────────┴────────────────────────────────────────────┘ ┌──────────────┬────────────────────────────────────────────────────────────────┐ │ Platform │ Value │ ├──────────────┼────────────────────────────────────────────────────────────────┤ │ OS │ macos Version 14.3.1 (Build 23D60) │ ├──────────────┼────────────────────────────────────────────────────────────────┤ │ Dart Locale │ en-ID │ ├──────────────┼────────────────────────────────────────────────────────────────┤ │ Dart runtime │ 3.2.6 (stable) (Wed Jan 24 13:41:58 2024 +0000) on "macos_x64" │ └──────────────┴────────────────────────────────────────────────────────────────┘