Flutter failed to write to a file mac code example

Example: Flutter failed to write to a file mac

When you are trying to call some flutter command and have such output:

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

It means you do not have sufficient permissions or the file belongs to another user.

What to do?
1) Go to provided directory with this to the file.

cd /Library/Flutter/bin/cache/
2) Check who is the owner By listing all of the files:

ls -l
with output: enter image description here

3) Change owner of this file to you

sudo chown -R $USER dart-sdk
provide password (needed by sudo) and click Enter

4) Check again who is the owner

file owner should be set for your current user

5) Repeat your flutter command

Tags:

Misc Example