DEV Community

nabbisen
nabbisen

Posted on • Originally published at scqr.net

2

Fix: Flutter doctor が permission denied で失敗 (Linux)

問題

Flutter 2 を Linux にインストールした時のことです。flutter doctor の実行が必要でした。

しかしながら実行すると、以下のような "Permission denied" エラーになりました。

$ flutter doctor
touch: cannot touch '/opt/flutter/bin/cache/.dartignore': Permission denied
Enter fullscreen mode Exit fullscreen mode

root すなわちスーパーユーザーで実行することが必要なのでしょうか ? いいえ。それは推奨されません:

$ sudo flutter doctor
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.
Enter fullscreen mode Exit fullscreen mode

Solution

使っているユーザーを "flutterusers" グループに加えてあげましょう。
Arch Linux での実行例です。こちらのコマンドを実行します:

$ sudo usermod -a -G flutterusers <your-user>
$ # alternatively:
$ #sudo gpasswd -a <your-user> flutterusers
Enter fullscreen mode Exit fullscreen mode

ログアウトして、ログインします。
ふたたび flutter doctor を実行しましょう。

$ flutter doctor
   Building flutter tool...
Enter fullscreen mode Exit fullscreen mode

成功です 🙂

補足: 別の方法 (非推奨)

違う方法もあります。/opt/flutter のパーミッションを変更することでも解決できるかもしれません。しかし上記の方法の方が推奨されるでしょう。

$ sudo chown -R <your-user>: /opt/flutter 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.