Rename-Item: Access to the path is denied (Flutter upgrade)

3,603

Solution 1

The problem is that Windows is unable to rename the dart-sdk folder. For me it was because the folder was locked by some processes. To solve such problem:

  1. Go to Resource Monitor (on windows 10 : Task Manager > Performance > Open Resource Monitor)
  2. CPU > Associated Handles
  3. Search for dart-sdk
  4. End processes locking the folder

Solution 2

Referring to @navid's reply:

YES! That worked for me. Slightly different path (win 10):

*open 'task manager'/ 'processes'*

and then just look for 'dart.exe' (couldn't install dart) or whatever is bothering you and re-run the process you wanted to work.

Solution 3

Close your IDE, open your flutter folder then folder bin, and run flutter.bin flutter.bin

The result must be like this:

cmd.exe result

If you do not close your IDE, you will see the same error in the cmd.exe window.

Solution 4

I would suggest to just close whatever IDE specifically either vs code or android studio running in the background and then run the "flutter upgrade" command again and it should work. Basically, what I think was happening in the backend was that flutter upgrade wasn't able to do the renaming and all because dart.exe was engaged in process by some other program (IDE in our case I suppose).

Solution 5

First try the solution on the image. Then try running your IDE as an administrator. If none of these solutions work, install your flutter sdk in a different directory and change the PATH variable.

enter image description here

Share:
3,603
amin jaafari
Author by

amin jaafari

Updated on December 20, 2022

Comments

  • amin jaafari
    amin jaafari over 1 year

    My previous Flutter version is installed in C:\src\flutter.

    When I try to upgrade Flutter, I get this error:

    Downloading Dart SDK from Flutter engine
    Rename-Item : Access to the path 'C:\src\flutter\bin\cache\dart-sdk' is denied.
    At C:\src\flutter\bin\internal\update_dart_sdk.ps1:51 char:5
    +     Rename-Item $dartSdkPath "$oldDartSdkPrefix$oldDartSdkSuffix"
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (C:\src\flutter\bin\cache\dart-sdk:String) [Rename-Item], IOException
        + FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand
    

    I think something is wrong with my drive permission on Windows, but I don't know how to solve it.

  • amin jaafari
    amin jaafari almost 4 years
    my problem solved that was because i had installed two sdk flutter in two different drives i deleted one of them my problem solved but a new issue created my android studio knows the old directory that i have delted although i set he new directory in setteing of android studio and system environment but the android studio says : Failed to start [cmd.exe] in E:/flutter my i installed it in c/src/flutter!
  • Vladyslav Ulianytskyi
    Vladyslav Ulianytskyi almost 3 years
    or just restart comuter