-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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] PathNotFoundException
when running flutter create
#142537
Comments
As the title suggests, we should catch the error when the user tries to provide a I could not get this reproduced on my macOS, there may be different behavior on Windows |
It actually looks to me like this is the intended behavior: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/create_base.dart#L145 And for some reason on Windows we're interpreting this trailing string as project name and NOT project directory. Now, whether |
I am unable to repro this on my Windows machine. Looking at recent stack traces, it looks like this is line where this happens:
This is surprising, because |
Looking at the implementations of |
Could be anti-virus software quarantining it soon after it's created. |
With EDIT: I see crash reports where |
PathNotFoundException
when running flutter create
with .
as the app namePathNotFoundException
when running flutter create .
cc: @brianquinlan |
The docs for
|
PathNotFoundException
when running flutter create .
PathNotFoundException
when running flutter create
The implementation of void createSync({bool recursive = false}) {
if (recursive) {
if (existsSync()) return;
if (path != parent.path) {
parent.createSync(recursive: true);
}
}
var result = _create(_Namespace._namespace, _rawPath);
if (result is OSError) {
throw FileSystemException._fromOSError(result, "Creation failed", path);
}
} So the only way that I can see how this would happen is if a parent directory is deleted between the time |
Deleting single file with
recursive: true when we delete single file.
|
Had some conversation with @brianquinlan and @aam (thanks folks!) where we discussed some fun theories, but we ultimately didn't come up with anything to explain how this could happen. I see a couple ways forward from here:
|
Note that this behavior goes back to at least 2021: #65242 (comment). Also note that #63540 improved user experience around various file access errors during project creation. Perhaps that could be extended over this file creation/direction creation. |
Thanks for digging this up!
Yeah, I think it's fair in situations like these (where we are truly stumped) to simply catch this exception and exit gracefully with a helpful message. If doing so ends up masking a legitimate bug in the tool, then we could still hope that there is a user out there willing to engage with us inside a new GitHub issue. |
Unassigning since I don't have high confidence that I will be fixing this within the next two weeks. I think another solution to this issue would be to augment |
Version:
stable/3.16.9
Command:
flutter create --template app --overwrite .
The text was updated successfully, but these errors were encountered: