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

[flutter_tools] pubspec.yaml environment.flutter constraint not respected by pub get #95472

Open
Tracked by #130635
neiljaywarner opened this issue Dec 17, 2021 · 23 comments
Labels
c: regression It was better in the past than it is now P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@neiljaywarner
Copy link

neiljaywarner commented Dec 17, 2021

steps to reproduce

  1. use current stable version flutter 2.8.1
  2. in pubspec.yaml use flutter: ">=2.8.0 <2.8.1" or "2.8.0"

Expected behaviour - flutter pub get error

The current Flutter SDK version is 2.8.1.

Because app_name requires Flutter SDK version <2.8.1, version solving failed.

Actual behaviour: pub get succeeds; vesrion constraint fails, overzealous dev or build server just ugpraded to a newer version of flutter without discussion or any testing at all or possibly even an easy OOTB way to see what version was built with

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Dec 20, 2021
@darshankawar
Copy link
Member

@neiljaywarner
Is there any reason why you need to change it to >=2.8.0 <2.8.1" or "2.8.0" ?
On latest stable 2.8.1, the dart version supported is 2.15.1 (from flutter doctor) .

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 20, 2021
@github-actions
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

@neiljaywarner
Copy link
Author

@darshankawar sorry I didn't see your question.
I want to pin it so if I go away for 6 to 18 months and come back I know what flutter version this project expects and will compile on.
Yes I know updating is important but so is keeping everyone on a project on the same tested version

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 10, 2022
@github-actions github-actions bot reopened this Jan 10, 2022
@neiljaywarner
Copy link
Author

neiljaywarner commented Jan 10, 2022 via email

@darshankawar
Copy link
Member

The current version with upper constraint I have is sdk: ">=2.8.1 <3.0.0" which works well, indicating the min lower and max upper version constraint, so I am not entirely sure what your request here is.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 11, 2022
@neiljaywarner
Copy link
Author

neiljaywarner commented Jan 11, 2022 via email

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 11, 2022
@darshankawar
Copy link
Member

Keeping it open and labeling for further input.

@darshankawar darshankawar added framework flutter/packages/flutter repository. See also f: labels. passed first triage and removed in triage Presently being triaged by the triage team labels Jan 12, 2022
@goderbauer goderbauer removed the framework flutter/packages/flutter repository. See also f: labels. label Feb 9, 2022
@neiljaywarner
Copy link
Author

neiljaywarner commented Feb 16, 2022

@darshankawar is it clear my goal now? I want to pin a specific version so neither ci/cd nor a new dev "accidentally" upgrades the flutter version for any builds they distribute to anybody and it won't compile at all on an incorrect flutter version. + @goderbauer
but instead that every single upgrade to flutter version no matter how small passes code review and qa and then every single developer has to use the specified flutter version when building the project.

@maheshmnj maheshmnj changed the title Upper version constraint in pubspec.yaml for flutter environment variable not working [Proposal]Ability to specify a specific flutter sdk version for a project in pubspec.yaml Apr 1, 2022
@maheshmnj maheshmnj added c: new feature Nothing broken; request for a new capability tool Affects the "flutter" command-line tool. See also t: labels. c: proposal A detailed proposal for a change to Flutter labels Apr 1, 2022
@maheshmnj
Copy link
Member

maheshmnj commented Apr 1, 2022

I am quite not sure if this is currently supported. I ran flutter pub get on stable 2.10.4 by specying the SDK versions as below in the pubspec.yaml

dependencies:
  flutter:
    sdk:  ">=2.5.1 <2.8.1"

and pub get fails with

Because test_app depends on flutter from SDK which doesn't exist (unknown SDK ">=2.5.1 <2.8.1"), version solving failed.

and using the below constraints still fails, so it makes me wonder if its a bug or is it not supported

dependencies:
  flutter:
    sdk:  ">=2.10.2 <2.13.0"
Because test_app depends on flutter from sdk which doesn't exist (unknown SDK ">=2.10.2 <2.13.0"), version solving failed.
pub get failed (server unavailable) -- attempting retry 9 in 64 seconds...

cc: @christopherfujino

@christopherfujino
Copy link
Member

christopherfujino commented Apr 2, 2022

Per https://dart.dev/tools/pub/pubspec#sdk-constraints, the way to do this is via the environment key, like:

environment:
  # This is the dart constraint
  sdk: '>=2.10.0 <3.0.0'
  # This is the Flutter SDK
  flutter: 2.8.0

From the link:

A Flutter SDK constraint is satisfied only if pub is running in the context of the flutter executable, and the Flutter SDK’s version file matches the given version constraint. Otherwise, the package will not be selected.

However, this doesn't seem to be enforced when I locally try this.

I believe this function call should be validating this: https://github.com/dart-lang/pub/blob/master/lib/src/validator/sdk_constraint.dart#L81

@neiljaywarner
Copy link
Author

@christopherfujino @darshankawar @maheshmnj yes, that's the whole point, it is supposed to work but doesn't.

@christopherfujino
Copy link
Member

@christopherfujino @darshankawar @maheshmnj yes, that's the whole point, it is supposed to work but doesn't.

@neiljaywarner you don't need to get snippy with me, I'm just documenting more context, to help solve this.

@neiljaywarner
Copy link
Author

neiljaywarner commented Apr 11, 2022 via email

@christopherfujino christopherfujino added c: regression It was better in the past than it is now and removed c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter labels May 5, 2022
@christopherfujino
Copy link
Member

Another filing of this in #80610

@christopherfujino
Copy link
Member

Ok, in playing around with this further, it seems that lower bounds are respected (e.g. flutter: '>=5.0.0' does throw an error) but upper-bounds are not (e.g. flutter: '<2.2.0' does not throw an error). Also, exact pins are ignored (e.g. flutter: '2.3.4' does not throw).

I believe there is a historical reason for this. Also, I imagine it would be difficult to enable upper bounds, as this would be a breaking change. However, it seems exact pins would be very useful, and would be relatively safe to enable.

@Hixie @mit-mit do you remember the context around this?

@mit-mit
Copy link
Member

mit-mit commented May 6, 2022

Yeah, I remember. We changed this to enable the roll-out of Flutter 2; prior to that we had both a lower and upper bound, but when we went to Flutter 2 -- which wasn't a major breaking release from a semver perspective -- we would have "broken the world", so we removed the upper-constraint.

Pinning to a single SDK is a request I've heard fairly often. It can be useful for teams that want to ensure all team members are on the same SDK. Unfortunately a constraint like flutter: x.y.z means use x.y.z as the lower and upper constraint, and sine the upper constraint is ignored in Flutter it's only a lower constraint.

@christopherfujino
Copy link
Member

Yeah, I remember. We changed this to enable the roll-out of Flutter 2; prior to that we had both a lower and upper bound, but when we went to Flutter 2 -- which wasn't a major breaking release from a semver perspective -- we would have "broken the world", so we removed the upper-constraint.

Pinning to a single SDK is a request I've heard fairly often. It can be useful for teams that want to ensure all team members are on the same SDK. Unfortunately a constraint like flutter: x.y.z means use x.y.z as the lower and upper constraint, and sine the upper constraint is ignored in Flutter it's only a lower constraint.

Is the blocker to enabling flutter: x.y.z to exactly constrain the version a technical or policy one?

@neiljaywarner
Copy link
Author

i also notice
flutter: "2.10.5" # pubspec.yaml

becomes
flutter: ">=2.10.5" # pubspec.lock

@simplifit-michael
Copy link

It is also a technical issue.
in my company we work on several project with several flutter versions.

eg:
one project is using flutter 3.3.2
the newest one is using flutter 3.7.0

=> the flutter_localizations of flutter 3.7.0 had breaking changes adding parameters. so when I want to use a string from the localisation it changed from being S.of(context)!.stringwithparameter.replaceAll('${parameter}',value) to S.of(context)!.stringwithparameter(value)
Also other dependencies have breaking changes if the flutter version is newer then the project defines.

Therefore a dev should be infomed when he uses a flutter version which is "too new"

hope that helps :)

@AlexV525
Copy link
Member

Using a fixed Flutter version would be enough for cases that force CI/CD not to accidentally upgrade to a newer version of Flutter (mostly happened during a new stable version released but the project has not been migrated). However, enabling version constraints like 3.10.x might be a little bit more helpful in a real-world project.

@christopherfujino christopherfujino added P2 Important issues not at the top of the work list triaged-tool Triaged by Flutter Tool team labels Jul 26, 2023
atsansone added a commit to dart-lang/site-www that referenced this issue Jan 13, 2024
Adding a note that the flutter version constraint is not fully enforced
-- see [this issue](flutter/flutter#95472)

---

- [x] I’ve reviewed the contributor guide and applied the relevant
portions to this PR.
- [x] This PR doesn’t contain automatically generated corrections or
text (Grammarly, LLMs, and similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.

<details>
  <summary>Contribution guidelines:</summary><br>

- See our [contributor
guide](https://github.com/dart-lang/site-www/blob/main/CONTRIBUTING.md)
for general expectations for PRs.
- Larger or significant changes should be discussed in an issue before
creating a PR.
- Code changes should generally follow the [Dart style
guide](https://dart.dev/effective-dart) and use `dart format`.
- Updates to [code
excerpts](https://github.com/dart-lang/site-shared/blob/main/doc/code-excerpts.md)
indicated by `<?code-excerpt` need to be updated in their source `.dart`
file as well.
</details>

---------

Co-authored-by: Anthony Sansone <atsansone@users.noreply.github.com>
Co-authored-by: Parker Lougheed <parlough@gmail.com>
atsansone added a commit to atsansone/site-www that referenced this issue Jan 26, 2024
Adding a note that the flutter version constraint is not fully enforced
-- see [this issue](flutter/flutter#95472)

---

- [x] I’ve reviewed the contributor guide and applied the relevant
portions to this PR.
- [x] This PR doesn’t contain automatically generated corrections or
text (Grammarly, LLMs, and similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.

<details>
  <summary>Contribution guidelines:</summary><br>

- See our [contributor
guide](https://github.com/dart-lang/site-www/blob/main/CONTRIBUTING.md)
for general expectations for PRs.
- Larger or significant changes should be discussed in an issue before
creating a PR.
- Code changes should generally follow the [Dart style
guide](https://dart.dev/effective-dart) and use `dart format`.
- Updates to [code
excerpts](https://github.com/dart-lang/site-shared/blob/main/doc/code-excerpts.md)
indicated by `<?code-excerpt` need to be updated in their source `.dart`
file as well.
</details>

---------

Co-authored-by: Anthony Sansone <atsansone@users.noreply.github.com>
Co-authored-by: Parker Lougheed <parlough@gmail.com>
@vasilich6107
Copy link
Contributor

Hi.
it would be nice to resolve this issue and make the version notation similar to how we work with them in other deps in pubspec.

The main issue is that it is not obvious if I specify flutter 3.3.2 that some magic code decides that it means >=3.3.2

@guneyozsan
Copy link

We migrated to flutter recently and flutter version installed among team was one of the first team issues we hit. Setting up a new machine, or coordinating version upgrades among team would be difficult. I can also foresee debugging weirdness in CI if it silently gets a breaking version of flutter.

In our case, we don't essentially need a range but locking to a wildcard version could be nice (e.g. 3.19.x or 3.x.x).

Also, the range silently failing is hard to notice unless you notice the difference in the diff:

pubspec.yaml:
flutter: '>=3.19.0 <4.0.0'
pubspec.lock:
flutter: ">=3.19.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: regression It was better in the past than it is now P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

No branches or pull requests