Problem
When I tried to install Flutter 2 on Linux, running flutter doctor
was required.
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.
Solution
Invite the user you use to "flutterusers" group.
Here is an Arch Linux example. Run this command:
$ sudo usermod -a -G flutterusers <your-user>
$ # alternatively:
$ #sudo gpasswd -a <your-user> flutterusers
Log out and login again.
Then, try flutter doctor
again.
$ flutter doctor
Building flutter tool...
Solved 🙂
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
Top comments (0)