Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission error when creating Flutter project

I am new to Flutter, and after installing it, I got this error when I tried to create a project.

[hello_world] flutter create --ios-language swift --android-language kotlin .
Failed to open or create the artifact cache lockfile: "FileSystemException: Cannot open file, path = '/home/raphael/flutter/flutter/bin/cache/lockfile' (OS Error: Permission denied, errno = 13)"
Please ensure you have permissions to create or open /home/raphael/flutter/flutter/bin/cache/lockfile
Failed to open or create the lockfile
exit code 1

I can't find any way to fix this, so I'd be glad if someone helps me :)

Thank you!

like image 320
Raphael Muller Avatar asked Sep 24 '19 19:09

Raphael Muller


People also ask

How do you add permissions to flutter?

Add the permissions your app needs to the android/app/src/main/AndroidManifest. xml. Put the permissions in the manifest tag, infront of the application tag. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.

How do you request for location permission in flutter?

In iOS, we require to add location permission Info. Now open an Info. plist file and add the below code based on the requirement. Change a string text to know why your application requires this permission. In iOS, all the permissions are default disabled.


3 Answers

Check permission for the mentioned directory via:

ls -l /home/raphael/flutter/

the flutter subfolder in there should have the same user id (or the group) as your current user, with whom you are trying to create the project.

If not, while being in the folder mentioned above, try to change permission on the folder via:

chown -R YOUR_USERNAME flutter

Run the first command again to verify that the apropriate user is now shown on the folder. Then try to create the project again.

like image 71
Logemann Avatar answered Dec 05 '22 23:12

Logemann


Try this:

sudo chown -R [user]:root /opt/flutter

It worked for me on Manjaro Linux.

like image 33
Pecinta kaffein Avatar answered Dec 05 '22 22:12

Pecinta kaffein


Try this, worked in my ubuntu 18.04.

First set the ownership of the folder:

sudo chown -R $USER:$USER ~/development/flutter

If you still have the error set this permission:

sudo chmod 754 development/flutter/
like image 29
Alexander De Jesus Marmolejos Avatar answered Dec 05 '22 21:12

Alexander De Jesus Marmolejos