Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Maintain project reference to cache versions after switch #681

Open
1 task done
bkleineibst opened this issue Mar 4, 2024 · 6 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@bkleineibst
Copy link

Before creating a bug report please make check the following

  • You have read our FAQ

Describe the bug
I use different versions of flutter in different branches of my repo. If I switch between branches, .settings.json references a version of flutter that doesn't necessarily exist anymore. I need to run fvm use to get the link to the correct version of flutter for the branch, for use from within vscode.

To Reproduce
Steps to reproduce the behavior:

  1. Create 2 branches.
  2. fvm use different flutter versions in each branch, and commit .fvmrc and .settings.json in each branch.
  3. Switch branches.
  4. Reload vscode.
  5. Will complain about missing flutter sdk.

Expected behavior
Should be able to switch branches and automatically use correct flutter version.

Desktop (please complete the following information):

  • OS: macos
  • FVM Version: 3.0.12

Additional context
fvm use seems to create a link to the appropriate version of flutter in the .fvm folder, and deletes other versions. If it kept other versions here, things should work, except on trying to use a new version that has not been used before.

@bkleineibst bkleineibst added the bug Something isn't working label Mar 4, 2024
@leoafarias
Copy link
Owner

@bkleineibst you should run "fvm install" to install the version that is configured.

The version is not "deleted" is just that the symlink gets removed.

Does the issue persist?

@bkleineibst
Copy link
Author

@leoafarias fvm install works, as does fvm use. However, both of these delete my comments from settings.json. I know I can use json formatted comments, but they just don't stand out.

The main question is why remove the symlinks for other flutter versions when switching flutter versions with fvm? If they were left there, I would not have to fvm install to get the folder back.

@leoafarias
Copy link
Owner

Ok, I understand now. I will look into it. However, I need a way to clean up at some point.

Maybe use flavors as the flag to check if it should be maintained?

@bkleineibst
Copy link
Author

@leoafarias My thinking is rather have symlinks to all installed flutter versions. There is very little cost of keeping all of them in each project. Maybe just delete symlinks in the project if their targets have been removed? I.e., keep symlinks in sync with all installed flutter versions.

@leoafarias leoafarias added enhancement New feature or request and removed bug Something isn't working labels Mar 5, 2024
@leoafarias leoafarias changed the title [BUG] Can't find flutter sdk after switching branches. [Enhancement] Maintain project reference to cache versions after switch Mar 5, 2024
@leoafarias
Copy link
Owner

@bkleineibst I have to think about it. FYI, some tools like melos and others depend on only one symlinks, which is flutter_sdk, that means that it is best practice to always rerun fvm install.

I think this should be handled by a trigger, on .vscode, maybe an FVM extension?

@bkleineibst
Copy link
Author

bkleineibst commented Mar 6, 2024

@leoafarias How about when fvm is run, it always checks to make sure that the flutter_sdk/version file matches the version specified in .fvmrc. If not, it triggers an install, but without updating settings.json. (assuming there is no reason to update it)

If a solution like this would work, would you then need the specific version symlink in the .fvm/versions folder? Couldn't settings.json always point to flutter_sdk? Would this not also obfuscate the need to update settings.json at all, except maybe on a first-time fvm use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants