创建 Flutter 项目时权限错误

Rap*_*ler 7 permissions ubuntu dart flutter

我是 Flutter 的新手,安装它后,当我尝试创建项目时出现此错误。

[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
Run Code Online (Sandbox Code Playgroud)

我找不到任何方法来解决这个问题,所以如果有人帮助我,我会很高兴:)

谢谢!

Mar*_*arc 27

通过以下方式检查上述目录的权限:

ls -l /home/raphael/flutter/
Run Code Online (Sandbox Code Playgroud)

那里的 flutter 子文件夹应该与您正在尝试创建项目的当前用户具有相同的用户 ID(或组)。

如果没有,在上面提到的文件夹中,尝试通过以下方式更改文件夹的权限:

chown -R YOUR_USERNAME flutter
Run Code Online (Sandbox Code Playgroud)

再次运行第一个命令以验证适当的用户现在是否显示在文件夹中。然后再次尝试创建项目。


小智 5

尝试这个:

sudo chown -R [user]:root /opt/flutter
Run Code Online (Sandbox Code Playgroud)

它在 Manjaro Linux 上对我有用。