-
Notifications
You must be signed in to change notification settings - Fork 230
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
make the logic to locate the Flutter SDK more robust #2307
Comments
Note that build_runner also needed to know if you were running from the flutter sdk or the dart sdk - you can check the We have an outstanding issue to have a fallback for older sdks that does some file system spelunking to figure it out. It would be good to establish a common way of determining if you are running from the flutter sdk (and its location). dart-lang/build#2528 is the issue for the build repo |
I'd like to get a bit more context - what is the use-case of calling It is not clear to me that Personally I'd like to put as little flutter-specific logic in the pub client as possible. But I think it would make sense to give a better error message explaining to use |
It is easier if you are a flutter developer to not bother installing the dart sdk twice, and instead add the one from flutter to your PATH. I don't have an idea of how common it actually is though. |
People do use the dart sdk embedded in the Flutter SDK, and @mit-mit has a proposal to make this an officially supported use case. Given that a very large portion of dart usage happens in the context of Flutter, having pub understand when it's in the context of a flutter sdk makes sense to me. It's odd to see a "can't find the flutter sdk" error message from pub when it's being run from the flutter sdk. |
Yup, +1 to establishing a simple, common mechanism for this. |
If they are adding the dart sdk from Flutter to their path it will work perfectly for dart projects, and the flutter command will work for flutter projects.
If we have an easy way of doing this I would be fine with pub using that in addition to FLUTTER_SDK. We would need both a way of knowing if we are run from a flutter sdk, and also a way of locating it. It would be awesome if it was a general mechanism for finding any sdk - I suspect we will have the same issue for Fuschia but that might be too far fetched for first iteration. |
The issue I ran into was that I had ~17 projects to run pub get for, and didn't know in advance whether they were regular dart projects or flutter projects.
I think this would likely look something like using Platform.resolvedExecutable, looking up the right number of directories, and recognizing that we were running from the context of a Flutter SDK. The relative location of the Dart sdk has been stable for quite a while, and we can likely graduate it to API with some discussion. Here's an example of the lookup logic: |
Note that in bazel the |
It would be nice to have a package for this - then the logic can change moving forward. |
You could just set FLUTTER_SDK before running pub get. |
Yes, but users are not going to know to do that. I really think it's odd that the |
Fwiw I think this behavior is pretty consistent with all binaries shipped with the sdk except maybe the analyzer. Granted, pub is a more user facing tool so it might make more sense for it to hardcode knowledge. |
If the flutter shipped version of I think it would be sensible to search up for a flutter SDK on the principle that if we can figure out what the user meant to do, we may as well do it. |
We want to keep the Dart sdk that is shipped with flutter as close to the normal Dart sdk as possible, so I would like to avoid this if we can. |
Actually you could run |
With flutter/flutter#53470 close to landing (exposing the cc @mit-mit as he's been driving exposing the |
To me |
@devoncarew and @jonahwilliams, do you agree that the dart script sets the FLUTTER_ROOT and that we can close this issue? |
If flutter's
|
And yup, given the above, I don't have concerns closing the issue. |
We should consider making We know exactly what is actually happening here (they are running |
The current message is:
Which is not all that bad IMO. |
Ah ok, I was basing the comment off of the original log in this issue |
@jonasfj, reconsider this on Monday.. |
@DanTup, @devoncarew reading up #2307, the current state of affairs is:
Let me know if you think we should reopen this again. I don't really mind introducing a new way to detect if we have Flutter available somewhere. In practice, if you have both Flutter SDK and Dart SDKs installed, then if you run Please reopen, if you think we need to revisit this. |
The failure mode we're seeing is:
Just for some additional clarity on the above, we are seeing failures even with just one Dart SDK installed (the one vended into the flutter sdk); not all paths for invoking |
Hmm, how is analysis server started? Does it have a But yeah, maybe we should fallback to detecting It just feels a bit messy to have all these strategies and fallbacks... It'll be hard to maintain and test properly.. It's likely to just break when / if the folder layout changes. Maybe we should have a |
I don't disagree - this introduces another row in the matrix of ways things could go wrong. What if we switch to only locating the Flutter SDK by relative path from the Dart SDK? The location has been the same more or less since the two SDKs started shipping together. If we elevate their relative locations to API, then a dependency like the one specified below:
would mean to look up from The nice thing about that is that Flutter is no longer special cased. Any other framework could vend the SDK, make sure their directory structure was set up as per convention, and have sdk packages - addressable from a pubspec file - in |
@jonasfj - some of our tooling features are blocked on this bug - things like doing code completion for package versions in pubspec files. I believe you were going to reconsider this? Happy to VC to discuss, or, this might make a good item for Q3 planning. |
@devoncarew yeah, we will look into this :) I agree, that we probably should just add more way to detect |
Thanks much! |
@jonasfj I tried this out now it's rolled into Flutter, and it seems to be working great, thanks! :-) |
When running
pub get
on a Flutter project, I see:This is when using the pub client that is embedded in the flutter sdk (
flutter/bin/cache/dart-sdk/bin/pub
). Currently the pub client only locates the Flutter sdk when the FLUTTER_SDK environment variable is set. We should expand this to also check if the specific instance of the pub tool itself is part of the Flutter sdk (something like usingPlatform.resolvedExecutable
, and verifying it's location).The text was updated successfully, but these errors were encountered: