fluttergithubdartpermissionsfile-permissions

When " flutter upgrade", I get "Permission denied" error


I would like to build a web application with Flutter. I followed this instruction. https://flutter.dev/docs/get-started/web I use Windows 10, Windows Subsystems for Linux, Debian 10.

I installed Flutter SDK in ~/development/ directory and have already set the path.

I input this.

flutter channel beta

And get this result.

Switching to flutter channel 'beta'...
git: From https://github.com/flutter/flutter
git:    5f21edf8b..b041144f8  stable         -> origin/stable
git:  * [new branch]          CareF-macrobenchmark-typo-fix -> origin/CareF-macrobenchmark-typo-fix
git:    c0d537ad3..311ad4bde  dart_development_service -> origin/dart_development_service
git:    456d80b9d..2f7a59a8d  dev            -> origin/dev
git:    5f21edf8b..b041144f8  flutter-1.17-candidate.3 -> origin/flutter-1.17-candidate.3
git:  * [new branch]          flutter-1.19-candidate.2 -> origin/flutter-1.19-candidate.2
git:  * [new branch]          flutter-1.19-candidate.3 -> origin/flutter-1.19-candidate.3
git:  * [new branch]          flutter-1.19-candidate.4 -> origin/flutter-1.19-candidate.4
git:    eacd1c8de..746749244  master         -> origin/master
git:  * [new tag]             1.17.3         -> 1.17.3
git:  * [new tag]             1.19.0-2.0.pre -> 1.19.0-2.0.pre
git:  * [new tag]             1.19.0-3.0.pre -> 1.19.0-3.0.pre
git:  * [new tag]             1.19.0-4.0.pre -> 1.19.0-4.0.pre
git: Switched to a new branch 'beta'
git: Branch 'beta' set up to track remote branch 'beta' from 'origin'.
Successfully switched to flutter channel 'beta'.
To ensure that you're on the latest build from this channel, run 'flutter
upgrade'

Next, I input this.

flutter upgrade

Then, I get this.

Downloading Dart SDK from Flutter engine ef9215ceb2884ddf520d321bcd822d1461330876...
mv: cannot move '/home/kazu/development/flutter/bin/cache/dart-sdk' to
'/home/kazu/development/flutter/bin/cache/dart-sdk.old': Permission denied

So, I read this NOTE. https://flutter.dev/docs/get-started/web#set-up

The flutter upgrade command silently fails when origin points to a personal fork. 
To validate that origin points to https://github.com/flutter/flutter.git, 
run the following commands in the root directory of your local copy of the 
https://github.com/flutter/flutter repository:

Then, I input this.

cd ~/development/flutter/
git remote get-url origin

Then my terminal returned this.

https://github.com/flutter/flutter.git

So, I tried again.

flutter upgrade

I got the same result.

Downloading Dart SDK from Flutter engine ef9215ceb2884ddf520d321bcd822d1461330876...
mv: cannot move '/home/kazu/development/flutter/bin/cache/dart-sdk' to
'/home/kazu/development/flutter/bin/cache/dart-sdk.old': Permission denied

Next, I tried sudo

sudo flutter upgrade

Then I got this.

sudo: flutter: command not found

Could you give me any advice please?


Solution

  • For me, The problem you got is the current user not have permission in dart-sdk folder. You need to re-check the permission or dart-sdk folder.

    Example run ls -la to see the details

    drwxr-xr-x 10 user-xxx staff 320 6 Jun 10:18 dart-sdk

    If not current user, using sudo chown to change owner of dart-sdk folder.

    try flutter upgrade again.

    Update Solution: (ref: github.com/flutter/flutter/issues/17898)