Fix Flutter doctor failed due to permission denied on Linux
- Mobile app development
- Published
- 1 min read
- @nabbisen
Table of contents
Problem Problem
When I tried to install Flutter (opens in a new tab) 2 on Linux (opens in a new tab), running flutter doctor was required (opens in a new tab).
Running it, however, resulted in the “Permission denied” error below.
$ flutter doctor
touch: cannot touch '/opt/flutter/bin/cache/.dartignore': Permission denied
Should I do it as root, superuser? No. It is not recommended:
$ sudo flutter doctor
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
解決方法 解決方法
Invite the user to “flutterusers” group. Here is an Arch Linux (opens in a new tab) example. Run this command:
$ sudo usermod -a -G flutterusers $USER
$ # alternatively:
$ #sudo gpasswd -a $USER flutterusers
Log out and login again.
Then, try flutter doctor again.
$ flutter doctor
Building flutter tool...
Solved 🙂
Optional: Another way (less recommended) Optional: Another way (less recommended)
Alternatively, it may be solved by changing /opt/flutter permission. But it is perhaps less recommended.
$ sudo chown -R <your-user>: /opt/flutter
More on: Build mobile apps
-
Flutter is one of the mobile app frameworks developed by Google which supports both Android and iOS.
-
Devuan GNU+Linux is a fork of Debian without systemd and hence Snaps (Snapd).
Scqr [secureal]
Scqr [secureal]: the engineering practice of Reflerd Inc. (opens in a new tab)
Comments and feedback are welcome.