首页 > 解决方案 > 创建 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

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

谢谢!

标签: ubuntuflutterdartpermissions

解决方案


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

ls -l /home/raphael/flutter/

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

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

chown -R YOUR_USERNAME flutter

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


推荐阅读