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 "version" file in repo root is missing and being created then deleted by the tool on branches named master/main #142521

Open
DanTup opened this issue Jan 30, 2024 · 7 comments
Labels
team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@DanTup
Copy link
Contributor

DanTup commented Jan 30, 2024

Steps to reproduce

I'm on the latest master (commit ccb2b44) and I noticed a number of things not working as expected in VS Code. It turns out, Dart-Code thinks I'm on Flutter version 0.0.0 and is therefore disabling all functionality that requires a specific Flutter version. This seems to be because I don't have the version file in the repo root.

I found #133097 while searching which seems to describe the same issue, however I'm on a much newer version than that (cc @christopherfujino )

Expected results

There should be a file named version in the root of the repository.

Actual results

There is no file.

Code sample

N/A

Screenshots or Video

PS C:\Dev\Google\flutter> flutter --version
Flutter 3.19.0-13.0.pre.32 • channel master • git@github.com:DanTup/flutter.git
Framework • revision ccb2b4439a (5 hours ago) • 2024-01-30 14:59:24 +0800
Engine • revision 438e9b4d7d
Tools • Dart 3.4.0 (build 3.4.0-82.0.dev) • DevTools 2.31.0
PS C:\Dev\Google\flutter> ls

    Directory: C:\Dev\Google\flutter

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          30/01/2024    11:24                .github
d----          19/12/2023    12:02                .vscode
d----          19/12/2023    12:02                bin
d----          30/01/2024    11:24                dev
d----          19/12/2023    12:02                examples
d----          01/06/2023    20:01                packages
-a---          30/01/2024    11:24         187181 .ci.yaml
-a---          01/06/2023    20:01            858 .gitattributes
-a---          19/12/2023    12:02           2932 .gitignore
-a---          19/12/2023    12:02          11615 analysis_options.yaml
-a---          30/01/2024    11:24           4714 AUTHORS
-a---          19/12/2023    12:02           2939 CODE_OF_CONDUCT.md
-a---          30/01/2024    11:24            489 CODEOWNERS
-a---          30/01/2024    11:24          11619 CONTRIBUTING.md
-a---          30/01/2024    11:24           2035 dartdoc_options.yaml
-a---          01/06/2023    20:01           1731 flutter_console.bat
-a---          01/06/2023    20:01           1544 LICENSE
-a---          01/06/2023    20:01           1124 PATENT_GRANT
-a---          30/01/2024    11:24           7055 README.md
-a---          30/01/2024    11:24          27988 TESTOWNERS

PS C:\Dev\Google\flutter>

Logs

No response

Flutter Doctor output

PS C:\Dev\Google\flutter> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel master, 3.19.0-13.0.pre.32, on Microsoft Windows [Version 10.0.22621.3007], locale en-GB)
    ! Warning: `dart` on your path resolves to C:\Dev\Tools\Dart\Stable\bin\dart.exe, which is not inside your current Flutter SDK checkout at
      C:\Dev\Google\flutter. Consider adding C:\Dev\Google\flutter\bin to the front of your path.
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.85.2)
[✓] VS Code (version 1.86.0-insider)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 1 category.
@DanTup
Copy link
Contributor Author

DanTup commented Jan 30, 2024

This is very odd... I can repro running from source and added some prints, and it seems like it is creating the file:

PS C:\Dev\Google\flutter\packages\flutter_tools> ../../bin/dart .\bin\flutter_tools.dart --version; ls ../..
Ensuring version file (_FlutterVersionGit)!
Inside _FlutterVersionGit.ensureVersionFile
Writing 3.19.0-13.0.pre.32 to LocalFile: 'C:\Dev\Google\flutter\version' using ErrorHandlingFileSystem
Calling LocalFile("C:\Dev\Google\flutter\version").writeAsStringSync()
Calling LocalFile("C:\Dev\Google\flutter\bin\cache\flutter.version.json").writeAsStringSync()
Flutter 3.19.0-13.0.pre.32 • channel master • git@github.com:DanTup/flutter.git
Framework • revision ccb2b4439a (5 hours ago) • 2024-01-30 14:59:24 +0800
Engine • revision 438e9b4d7d
Tools • Dart 3.4.0 (build 3.4.0-82.0.dev) • DevTools 2.31.0

And nothing in the delete calls prints, so it doesn't seem like it's being deleted.

I'll try to debug a bit more shortly... This could be a big issue if widespread, because VS Code uses this version to switch quite a bit of Dart-Code functionality.

@DanTup
Copy link
Contributor Author

DanTup commented Jan 30, 2024

@christopherfujino here is the issue:

Inside _FlutterVersionGit.ensureVersionFile
Writing 3.19.0-13.0.pre.32 to LocalFile: 'C:\Dev\Google\flutter\version' using ErrorHandlingFileSystem
Calling LocalFile("C:\Dev\Google\flutter\version").writeAsStringSync()
Exists now? true
Calling LocalFile("C:\Dev\Google\flutter\bin\cache\flutter.version.json").writeAsStringSync()
Exists now? true
Deleting the new version file!!!!!!
Deleting the legacy version file!!!!!!

The files are being deleted by:

legacyVersionFile.deleteSync();

Stack trace is like:

#0      new FlutterVersion (package:flutter_tools/src/version.dart:111:26)
#1      FlutterVersion.fetchTagsAndGetVersion (package:flutter_tools/src/version.dart:178:12)
#2      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:338:65)
<asynchronous suspension>
#3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#4      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:294:5)

It's created here on line 311 and then deleted because of the call on line 338:

image

Doesn't seem to affect beta, but I haven't yet figured out why, since most of the code seems the same.

@DanTup
Copy link
Contributor Author

DanTup commented Jan 30, 2024

Ok, the reason this doesn't happen on beta is because of this early exit, which prevents the constructor running that deletes the file:

if (channel != 'master' && channel != 'main') {
return this;
}

So the issue is isolated to branches named master/main.

@DanTup DanTup changed the title Flutter "version" file in repo root is missing and not being created by the tool Flutter "version" file in repo root is missing and being created then deleted by the tool on branches named master/main Jan 30, 2024
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Jan 30, 2024
@darshankawar
Copy link
Member

Thanks for the detailed report and analysis. Labeling this for tracking.

@darshankawar darshankawar added tool Affects the "flutter" command-line tool. See also t: labels. team-tool Owned by Flutter Tool team and removed in triage Presently being triaged by the triage team labels Jan 30, 2024
@eliasyishak
Copy link
Contributor

@christopherfujino leaving to you for prioritizing

@DanTup
Copy link
Contributor Author

DanTup commented May 8, 2024

Not sure if it's the same thing, but I just noticed that the GitHub actions are often failing the coverage step because the Flutter version is reported as 0.0.0-unknown:

image

Example: https://github.com/flutter/flutter/actions/runs/8999603670/job/24722091985

@christopherfujino
Copy link
Member

Not sure if it's the same thing, but I just noticed that the GitHub actions are often failing the coverage step because the Flutter version is reported as 0.0.0-unknown:

image

Example: https://github.com/flutter/flutter/actions/runs/8999603670/job/24722091985

TIL we try to upload coverage from actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

No branches or pull requests

4 participants