flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Endless Rename-Item errors during Flutter Upgrade (Android Studio)

Open deakjahn opened this issue 1 year ago • 7 comments

For the last few Flutter upgrades, I was unable to update from inside Android Studio.

Steps to Reproduce

Flutter Upgrade from inside Android Studio gives an endless loop of the following errors. Leaving AS and upgrading from the Flutter console works flawlessly.

P:\Flutter\bin\flutter.bat --no-color upgrade
Upgrading Flutter to 3.24.3 from 3.24.2 in P:\Flutter...
Checking Dart SDK version... 
Downloading Dart SDK from Flutter engine 36335019a8eab588c3c2ea783c618d90505be233... 
Rename-Item : The process cannot access the file because it is being used by another process.
At P:\Flutter\bin\internal\update_dart_sdk.ps1:74 char:9
+         Rename-Item $dartSdkPath "$oldDartSdkPrefix$oldDartSdkSuffix"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (P:\Flutter\bin\cache\dart-sdk:String) [Rename-Item], IOException
    + FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand

Error: Unable to update Dart SDK. Retrying... 
ERROR: Input redirection is not supported, exiting the process immediately.
Checking Dart SDK version... 
Downloading Dart SDK from Flutter engine 36335019a8eab588c3c2ea783c618d90505be233... 
Rename-Item : The process cannot access the file because it is being used by another process.
At P:\Flutter\bin\internal\update_dart_sdk.ps1:74 char:9
+         Rename-Item $dartSdkPath "$oldDartSdkPrefix$oldDartSdkSuffix"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (P:\Flutter\bin\cache\dart-sdk:String) [Rename-Item], IOException
    + FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand

Error: Unable to update Dart SDK. Retrying... 
ERROR: Input redirection is not supported, exiting the process immediately.
Checking Dart SDK version... 

Version info

P:\Flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22631.4169], locale en-US)
    • Flutter version 3.24.3 on channel stable at P:\Flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (2 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at P:/Android_SDK
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = P:/Android_SDK
    • ANDROID_SDK_ROOT = p:\Android_SDK
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.11.35312.102
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)

[√] Connected device (2 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.4169]
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 129.0.2792.52

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
Process finished with exit code 0

deakjahn avatar Sep 27 '24 09:09 deakjahn

This is because the Dart instance is running and it cannot be overwrite. You need to close all instances (here we should close the editor) to get it work.

AlexV525 avatar Mar 02 '25 12:03 AlexV525

Sorry, this will not do.

Yes, we know why it doesn't work, we all know perfectly well. But you put an upgrade facility into the IDE, not us. Either you leave it there and make sure it works (a possible solution would be to offer to close the IDE and start the upgrade then), or you remove the functionality. Simply stating that "although it's there, we put it there, we don't plan to make it functional again" is not an acceptable answer.

deakjahn avatar Mar 02 '25 12:03 deakjahn

Could you provide a screenshot of that upgrade button section?

To be clear, there is no "us" when you are talking about people who made those changes, because the plugin was developed by hundreds of people and some of them are may not work with Flutter anymore. I'm only a active user that helps to triage. Please keep our talk respects the CoC, thanks.

AlexV525 avatar Mar 02 '25 12:03 AlexV525

Image

I never use ad hominem arguments and you won't experience any personal attacks from me, either, don't be afraid. :-) But stating that I don't think a "we won't fix" approach is acceptable in this situation is well within the CoC.

This used to work, it's a regression. I don't know how it was solved earlier, maybe the instance allowed a stop-upgrade-restart signal or some other solution, I don't know. But the UI is clearly there, people are expecting it to function and nothing tells them why it doesn't work or what to do instead. If it really can't be solved and no co-operation with the Dart crowd can make it work, then, at least, pop up a dialog box describing the solution.

We can't know your actual status in the project. We, as users, report bugs and if somebody answers with "we won't fix" or "not planned", we have to assume you do it with some authority, belonging to the bunch of people who are responsible for the plugin and its operation and can have an educated guess as to what can be solved and what should be solved.

deakjahn avatar Mar 02 '25 13:03 deakjahn

The above info is helpful to determine what is going on. Reopening for further investigations.

AlexV525 avatar Mar 02 '25 13:03 AlexV525

Thanks.

deakjahn avatar Mar 02 '25 13:03 deakjahn

I just did some digging into code changes with the plugin upgrade action. There have been no related changes since 2017. I suspect that the upgrade command used to terminate the Dart process but no longer does so. At this point, I would suggest seeking help with the framework (specifically flutter_tool).

AlexV525 avatar Mar 02 '25 14:03 AlexV525

@deakjahn thanks for the additional info and @AlexV525 thanks for the triage! I don't think this falls into our near-term priorities but it may be a good issue for a code quality sprint or as a starter issue. i.e. investigate whether there's another way to terminate the process gracefully, what impacts to plugin might be, and/or decide to show a message to users to shut down IDE and restart.

helin24 avatar Sep 03 '25 19:09 helin24

FWIW, this same experience occurs with ANY of the Tools acting under the scope of the flutter cli as it appears to perform and in-place upgrade the first time they are run. None of them work from within IntelliJ (Windows at least). I've since abandoned them altogether.

skowronek avatar Nov 21 '25 23:11 skowronek