当“flutter upgrade”时,我得到 "Permission denied" 错误
When " flutter upgrade", I get "Permission denied" error
我想用 Flutter 构建一个 Web 应用程序。我遵循了这个指示。 https://flutter.dev/docs/get-started/web
我使用 Windows 10,Windows 子系统 Linux,Debian 10.
我在~/development/
目录下安装了Flutter SDK,并且已经设置好路径
我输入这个。
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
你能给我一些建议吗?
对我来说,您遇到的问题是当前用户没有 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
在 flutter 升级之前
当您尝试调用一些 flutter
命令并得到这样的输出时:
Downloading Dart SDK from Flutter engine 40441def692f444660a11e20fac37af9050245ab...
mv: rename /Library/Flutter/bin/cache/dart-sdk
to /Library/Flutter/bin/cache/dart-sdk.old: Permission denied
说明您没有足够的权限或文件属于其他用户。
怎么办?
1) 将此文件转到提供的目录。
cd /Library/Flutter/bin/cache/
2) 检查所有者是谁
通过列出所有文件:
ls -l
输出:
3) 将此文件的所有者更改为您
sudo chown -R $USER dart-sdk
提供密码(sudo
需要)并单击输入
4)再次检查谁是所有者
应为您当前的用户设置文件所有者
5) 重复您的 flutter
命令
我想用 Flutter 构建一个 Web 应用程序。我遵循了这个指示。 https://flutter.dev/docs/get-started/web 我使用 Windows 10,Windows 子系统 Linux,Debian 10.
我在~/development/
目录下安装了Flutter SDK,并且已经设置好路径
我输入这个。
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
你能给我一些建议吗?
对我来说,您遇到的问题是当前用户没有 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
在 flutter 升级之前
当您尝试调用一些 flutter
命令并得到这样的输出时:
Downloading Dart SDK from Flutter engine 40441def692f444660a11e20fac37af9050245ab...
mv: rename /Library/Flutter/bin/cache/dart-sdk
to /Library/Flutter/bin/cache/dart-sdk.old: Permission denied
说明您没有足够的权限或文件属于其他用户。
怎么办?
1) 将此文件转到提供的目录。
cd /Library/Flutter/bin/cache/
2) 检查所有者是谁 通过列出所有文件:
ls -l
输出:
3) 将此文件的所有者更改为您
sudo chown -R $USER dart-sdk
提供密码(sudo
需要)并单击输入
4)再次检查谁是所有者
应为您当前的用户设置文件所有者
5) 重复您的 flutter
命令