leoafarias / fvm

Flutter Version Management: A simple CLI to manage Flutter SDK versions.
https://fvm.app
MIT License
4.73k stars 233 forks source link

[BUG] In "fvm use x.y.z" command, it uses home directory instead of current cmd project directory #769

Open bsudhanva opened 3 months ago

bsudhanva commented 3 months ago

Before creating a bug report please make check the following

Describe the bug

A clear and concise description of what the bug is. when i use "fvm use x.y.z" commands it considers my root/home directory and creates a .fvmrc in it, instead of my project directory

To Reproduce Steps to reproduce the behavior:

  1. Go to terminal.. cd /d pat/to/project_ directory or within vscode terminal
  2. Run fvm use stable...
  3. it gives following output
    
    PS C:\Users\myusername\projects\learningdart> fvm use stable

Using .fvmrc in C:\Users\myusername

If this is incorrect either use the --force flag or remove the .fvmrc and the .fvm directory.

Skipping "pub get" because no pubspec.yaml found.

✓ Project now uses Flutter SDK : Channel: Stable

incase you use --force 

fvm use stable --force [WARN] Not checking for version mismatch as --force flag is set. Skipping "pub get" because no pubspec.yaml found.

✓ Project now uses Flutter SDK : Channel: Stable


**Expected behavior**
I expect it to consider my current directory as my project directory instead of my home directory

**Logs**

C:\Users\MyUserName\projects\learningdart> fvm doctor FVM Doctor:

Project: │ Project │ MyUsername │ ├─────────────────────────────┼──────────────────────────────────────┤ │ Directory │ C:\Users\Myusername │ ├─────────────────────────────┼──────────────────────────────────────┤ │ Active Flavor │ None │ ├─────────────────────────────┼──────────────────────────────────────┤ │ Is Flutter Project │ No



**Desktop (please complete the following information):**

- OS: Win 11 x64
- FVM Version 3.1.7

**Workaround**
delete any ".fvm folder" and ".fvmrc file"  as suggested by fvm 

for example.
C:\ A\B\C\D\MyProjectFolder

even though command prompt is at MyProject folder directory, it'll first check the highest directory and then to the lower one i.e A then B then C and then D and finally the actual project.
So check these and delete the mentioned files and folder
leoafarias commented 3 months ago

@bsudhanva We cannot assume the current directory as the project directory due to the monorepo setup. However, maybe we can do some printing or logging to let people know which directory it is using. Also, you can force the creation of a .fvmrc in that directory by using the --force flag.