Skip to content

feat: allow fixed flutter version constraints. #4578

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eseidel
Copy link

@eseidel eseidel commented May 14, 2025

Previously there was code to treat x.y.z as >=x.y.z, specifically for the flutter sdk version constraint. This change removes that which allows app authors to specify an upper bound on the flutter version constraint for their projects.

This isn't actually ready for landing, because I haven't yet been able to successfully get a clean run of pub tests locally on my mac (maybe they aren't expected to run cleanly on a mac?) even without any changes to pub.

Fix for flutter/flutter#95472.

Previously there was code to treat x.y.z as >=x.y.z, specifically
for the flutter sdk version constratint.  This change removes that
which allows app authors to specify an upper bound on the flutter
version constraint for their projects.
@njwandroid
Copy link

very exciting @eseidel thank you so much

@eseidel
Copy link
Author

eseidel commented May 14, 2025

Yeah, even following all instructions (installing a fresh dart-only sdk, etc) I still get 7 failures locally (even without this change) making it very difficult to work on pub.
failures.txt

@sigurdm
Copy link
Contributor

sigurdm commented May 15, 2025

Sorry about the failures. We have CI running on mac where all tests are passing, but I usually develop on linux.

I have just run all tests successfully on my mac.

It seems from the stack traces that there is some problem with running freshly compiled subprocesses. Do you have any protection in place that only allows you to run recognized binaries?

@sigurdm
Copy link
Contributor

sigurdm commented May 15, 2025

About the PR itself. The special casing is there for a reason - we don't want packages to claim compatibility with some flutter , and then flutter publishes a new major version (for marketing purposes) and then you cannot use the old packages.

I personally was not too fond of this hack it back when it was put in place, but as long as Flutter insists to use its major version for marketing, and not for semantic versioning we need something like this hack in place for the ecosystem to continue working.

We could consider changing again slightly how we interpret flutter sdk constraints. Perhaps

  • We in general ignore the upper bound of the constraint
  • But if the constraint is a single version we respect both the upper and lower bound (ie. we constrain to just that version).

Or another plausible solution would be

  • We in general respect upper and lower bound of the constraint
  • Unless it is a '^x.y.z' constraint, in which case we just consider the lower bound.

Each of these have the potential to be breaking changes. And we would need to run a feasibility analysis across all current packages on pub.dev to see how many packages are affected.

cc @mit-mit @jonasfj

@njwandroid
Copy link

njwandroid commented May 15, 2025 via email

@eseidel
Copy link
Author

eseidel commented May 15, 2025

re: freshly compiled subprocesses. Not to my knowledge. This is a mostly-unaltered apple M3.

@sigurdm
Copy link
Contributor

sigurdm commented May 16, 2025

Can you repeat here some of the reasons you want to pin the flutter sdk version?

Perhaps we need a separate mechanism for that.

@njwandroid
Copy link

njwandroid commented May 16, 2025 via email

@eseidel
Copy link
Author

eseidel commented May 16, 2025

The problem we (Shorebird) were looking to solve is that @sigurdm there is currently no official way to record "this set of source should use version X.Y.Z of flutter". I'm not sure this constraint is the right way to record that. Also, as currently implemented, if one used this constraint, one would need to look at the pubspec.yaml rather than pubspec.lock because the spec might say 1.2.3 but the lock will say >=1.2.3.

My understanding is that the real problem here (ignoring this potential solution) is that this "hack" was added for libraries, but the problem that flutter/flutter#95472 is looking for a solution for is for apps (that want to record somehow the exact version of Flutter the developer should use).

There are lots of 3p attempts at this. fvm, puro, etc. have per-package "lock" files for a flutter version. There is just no "flutter official" place to put this information, so either we (shorebird) make yet another way, fix this one, or bless one of these 3p ways as being the "standard".

In any case, I should be clear, I don't feel super passionate about this. We were just trying to change our shorebird command line to look up what Flutter version to use for a project, tried to use this mechanism and realized it was "broken" for that use case and then I looked briefly into fixing it and sent this PR.

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

Successfully merging this pull request may close these issues.

3 participants