首页 > 解决方案 > 当“颤振升级”时,我得到“权限被拒绝”错误

问题描述

我想用 Flutter 构建一个 Web 应用程序。我遵循了这个指示。https://flutter.dev/docs/get-started/web 我使用 Windows 10、适用于 Linux 的 Windows 子系统、Debian 10。

我在目录中安装了 Flutter SDK~/development/并且已经设置了路径。

我输入这个。

flutter channel beta

并得到这个结果。

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'

接下来,我输入这个。

flutter upgrade

然后,我明白了。

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

所以,我读了这篇笔记。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:

然后,我输入了这个。

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

然后我的终端返回了这个。

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

于是,我又试了一次。

flutter upgrade

我得到了同样的结果。

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

接下来,我尝试了sudo

sudo flutter upgrade

然后我得到了这个。

sudo: flutter: command not found

你能给我什么建议吗?

标签: fluttergithubdartpermissionsfile-permissions

解决方案


dart-sdk对我来说,您遇到的问题是当前用户在文件夹中没有权限。您需要重新检查权限或dart-sdk文件夹。

示例运行ls -la查看详细信息

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

如果不是当前用户,sudo chown则用于更改dart-sdk文件夹的所有者。

再试flutter upgrade一次。

更新解决方案:(参考:github.com/flutter/flutter/issues/17898)

  • 手动将 dart-sdk 重命名为其他可以解决问题的名称。
  • git clean -xffd git pull flutter doctor或在颤振升级之前运行此命令

推荐阅读