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

Allow flutter_rust_bridge_codegen to use fvm flutter #2300

Open
BriceCroix opened this issue Sep 15, 2024 · 7 comments
Open

Allow flutter_rust_bridge_codegen to use fvm flutter #2300

BriceCroix opened this issue Sep 15, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@BriceCroix
Copy link

Hi, first of all thank you all for this awesome project.

I would like to know if it is possible to use flutter_rust_bridge_codegen utility with fvm flutter. I do not have the regular flutter command on my computer and do not wish to install it. If you do not know FVM it is an elegant solution to manage the flutter version used by each specific project, here is its main website.

As of now, the executable exits with the following error message :

+ & "flutter" "pub" "add" "rust_lib_myproject" "--path=rust_builder"
+   ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (flutter:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I could not find any information about fvm in the documentation of this repository but perhaps I did not look at the right place.

If this is not possible right now, I think it would be great to add something like a --use-fvm or --flutter-path /path/to/fvm/flutter option to the codegen call.

Thanks a lot for your time !

@BriceCroix BriceCroix added the enhancement New feature or request label Sep 15, 2024
Copy link

welcome bot commented Sep 15, 2024

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented Sep 16, 2024

Looks reasonable and feel free to PR (since this does not look very hard)! Alternatively I may work on it later.

We may need to determine how to know whether to use fvm or normal flutter binary. One way may be, try to see whether fvm exists (maybe execute fvm --help and see return code is zero or nonzero), and if exists use it, otherwise do not use it.

Btw, we may also handle fvm dart (instead of dart) as well.

I guess code change may be near

pub(crate) fn as_run_command(&self) -> Vec<PathBuf> {

@BriceCroix
Copy link
Author

Thanks for looking into this ! I think the best way to determine if flutter must be used from global install or from fvm is to look for a .fvmrc file in the project directory.

Alternatively before its version 3.0, fvm used to get its configuration from the .fvm/fvm_config.json project file. One may also look for this file.

I agree that supporting pure fvm dart would also be great, I will look into how fvm configures itself in that case.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Sep 16, 2024

I think the best way to determine if flutter must be used from global install or from fvm is to look for a .fvmrc file in the project directory.

Looks reasonable! Sometimes .fvm directory is from parent folder, so we may need to recursively check as well.

Alternatively before its version 3.0

Looks like we only need to support latest fvm and no worries about old versions

@patmuk
Copy link
Contributor

patmuk commented Sep 26, 2024

@BriceCroix, if you can't wait for the fix, why don't you create an alias so that flutter calls fvm flutter, as described in https://fvm.app/documentation/guides/running-flutter#call-sdk-directly ?

Alternatively I can recommend using nix flake. I use it in my project.

@BriceCroix
Copy link
Author

@BriceCroix, if you can't wait for the fix, why don't you create an alias so that flutter calls fvm flutter, as described in https://fvm.app/documentation/guides/running-flutter#call-sdk-directly ?

Alternatively I can recommend using nix flake. I use it in my project.

Yes I ended up adding fvm's internal directories to my path so that flutter is found, this is a nice workaround but I still think calling the version of flutter required by a specific project through the .fvmrc would be a great feature.

I started to look into but but hadn't had much time to come up with something

@patmuk
Copy link
Contributor

patmuk commented Sep 27, 2024

Yes I ended up adding fvm's internal directories to my path so that flutter is found, this is a nice workaround but I still think calling the version of flutter required by a specific project through the .fvmrc would be a great feature.

Ah, great :) Hmm, I understood that this is solved as well, that

sudo echo 'fvm flutter ${@:1}' > "/usr/local/bin/flutter" && sudo chmod +x /usr/local/bin/flutter

is binding the command flutter to fvm flutter - and thus fvm takes care to take the flutter version specified in the project.

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

3 participants