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 not found during flutter pub get #133093

Open
christopherfujino opened this issue Aug 22, 2023 · 4 comments · Fixed by #133097
Open

flutter version file not found during flutter pub get #133093

christopherfujino opened this issue Aug 22, 2023 · 4 comments · Fixed by #133097
Labels
P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team triaged-tool Triaged by Flutter Tool team

Comments

@christopherfujino
Copy link
Member

christopherfujino commented Aug 22, 2023

on beta/3.14.0-0.1.pre (on linux)
with command flutter pub get

PathNotFoundException: Cannot open file, path = '/home/ping/.puro/envs/beta/flutter/version' (OS Error: No such file or directory, errno = 2)
at _File.throwIfError(file_impl.dart:675)
at _File.openSync(file_impl.dart:490)
at _File.readAsBytesSync(file_impl.dart:574)
at _File.readAsStringSync(file_impl.dart:624)
at ForwardingFile.readAsStringSync(forwarding_file.dart:99)
at ErrorHandlingFile.readAsStringSync.<anonymous closure>(error_handling_io.dart:218)
at _runSync(error_handling_io.dart:590)
at ErrorHandlingFile.readAsStringSync(error_handling_io.dart:217)
at _DefaultPub._updateVersionAndPackageConfig(pub.dart:705)
at _DefaultPub.interactively(pub.dart:538)
at <asynchronous gap>(async)
at PackagesGetCommand.runCommand(packages.dart:314)
at <asynchronous gap>(async)
at FlutterCommand.run.<anonymous closure>(flutter_command.dart:1323)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at CommandRunner.runCommand(command_runner.dart:212)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand.<anonymous closure>(flutter_command_runner.dart:339)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand(flutter_command_runner.dart:285)
at <asynchronous gap>(async)
at run.<anonymous closure>.<anonymous closure>(runner.dart:115)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at main(executable.dart:90)
at <asynchronous gap>(async)
@christopherfujino christopherfujino added team-tool Owned by Flutter Tool team P1 High-priority issues at the top of the work list triaged-tool Triaged by Flutter Tool team labels Aug 22, 2023
@christopherfujino
Copy link
Member Author

I think the issue here is that the implementation of _FlutterVersionFromFile.ensureVersionFile() is a no-op because the file //flutter/bin/cache/flutter.version.json exists, however, this method should ALSO ensure that //flutter/version exists.

fluttermirroringbot pushed a commit that referenced this issue Aug 23, 2023
Fixes #133093

When I introduced the new, more robust version file `//flutter/bin/cache/version.json` in #124558, I changed `class FlutterVersion` into an abstract interface, implemented by `_FlutterVersionFromGit` (which is essentially the previous behavior) and `_FlutterVersionFromFile`, which merely reads the data it would have computed via git from `//flutter/bin/cache/version.json`.

While doing this, I made `_FlutterVersionFromGit.ensureVersionFile()` to be a no-op, since I assumed this would not be necessary since we already had a version file in the cache. However, this method was what was previously responsible for ensuring `//flutter/version` existed on disk. This means that if, for whatever reason, the user had `//flutter/bin/cache/flutter.version.json` present but NOT `//flutter/version`, the tool would have never created that file, and they would hit the tool crash seen in #133093.

This fixes the tool by ensuring `//flutter/version` exists regardless of if we're hydrating `FlutterVersion` from `//flutter/bin/cache/flutter.version.json` or not.
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2023
@christopherfujino
Copy link
Member Author

christopherfujino commented Sep 20, 2023

Looks like this is still happening on the beta 3.15 release, which had my proposed fix: https://github.com/flutter/flutter/blob/beta/packages/flutter_tools/lib/src/version.dart#L536-L541:

PathNotFoundException: Cannot open file, path = '/home/flutter/snap/flutter/common/flutter/version' (OS Error: No such file or directory, errno = 2)
at _File.throwIfError(file_impl.dart:675)
at _File.openSync(file_impl.dart:490)
at _File.readAsBytesSync(file_impl.dart:574)
at _File.readAsStringSync(file_impl.dart:624)
at ForwardingFile.readAsStringSync(forwarding_file.dart:99)
at ErrorHandlingFile.readAsStringSync.<anonymous closure>(error_handling_io.dart:218)
at _runSync(error_handling_io.dart:590)
at ErrorHandlingFile.readAsStringSync(error_handling_io.dart:217)
at _DefaultPub._updateVersionAndPackageConfig(pub.dart:705)
at _DefaultPub.interactively(pub.dart:538)
at <asynchronous gap>(async)
at PackagesGetCommand.runCommand(packages.dart:342)
at <asynchronous gap>(async)
at FlutterCommand.run.<anonymous closure>(flutter_command.dart:1323)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at CommandRunner.runCommand(command_runner.dart:212)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand.<anonymous closure>(flutter_command_runner.dart:348)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand(flutter_command_runner.dart:294)
at <asynchronous gap>(async)
at run.<anonymous closure>.<anonymous closure>(runner.dart:113)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at main(executable.dart:90)
at <asynchronous gap>(async)

@flutter-triage-bot flutter-triage-bot bot unlocked this conversation Sep 20, 2023
@flutter-triage-bot flutter-triage-bot bot removed the triaged-tool Triaged by Flutter Tool team label Feb 12, 2024
@flutter-triage-bot
Copy link

This issue is marked P1 but has had no recent status updates.

The P1 label indicates high-priority issues that are at the top of the work list. This is the highest priority level a bug can have if it isn't affecting a top-tier customer or breaking the build. Bugs marked P1 are generally actively being worked on unless the assignee is dealing with a P0 bug (or another P1 bug). Issues at this level should be resolved in a matter of months and should have monthly updates on GitHub.

Please consider where this bug really falls in our current priorities, and label it or assign it accordingly. This allows people to have a clearer picture of what work is actually planned. Thanks!

@christopherfujino christopherfujino added P2 Important issues not at the top of the work list triaged-tool Triaged by Flutter Tool team and removed P1 High-priority issues at the top of the work list labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant