Android Studio 设置 - 清除只读状态 [英] Android Studio setup - Clear Read-Only Status

查看:265
本文介绍了Android Studio 设置 - 清除只读状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

未获得写入特定文件夹的权限.Android Studio 会问这个.只有我可以点击取消"按钮.

Permission to write to certain folder isn't obtained. Android Studio asks this. Only thing I can click on "Cancel" button.

之后,当我想离开 Android Studio 时,我收到无法保存项目".

Afterwards, when I want to leave Android Studio I get "could not save project".

  • 项目是从 git 存储库下载的.
  • 在其他 Mac 上运行良好.
  • 项目下载到用户/项目/项目名称.
  • 尝试使用权限但没有成功
  • 尝试更改项目目录位置(同一目录中的另一个项目正在运行)
  • 安装所有可能的包

Android studio 中的锁定图标.

Locked icons in Android studio.

我需要什么建议来寻找解决方案?

I need any suggestion in what direction to look for solution?

推荐答案

最可能的解释是该目录及其所有文件由系统上的不同用户帐户拥有.通常,清除只读访问"对话框会在可能的情况下修复读取权限问题;如果不是(因为文件归另一个用户所有),对话框将拒绝让您单击确定"按钮.

The most likely explanation is that the directory and all its files are owned by a different user account on the system. Normally the "Clear Read-Only Access" dialog will fix up read permission problems if it's possible to do so; if it's not (because the files are owned by another user), the dialog will refuse to let you click the OK button.

您可以从 MacOS 终端使用 ls 命令确认这一点.这是我的一个随机项目的示例.

You can confirm this by using the ls command from the MacOS terminal. Here's an example from a random project of mine.

sbarta-macbookpro2:~/AndroidStudioProjects/ASProject$ ls -alh
total 80
-rw-r--r--  1 foo   eng   438B Jan  9 10:54 local.properties
-rw-r--r--  1 foo   eng   853B Jan  9 10:54 gradle.properties
drwxr-xr-x  3 foo   eng   102B Jan  9 10:54 gradle

如果您运行 man ls,您可以阅读 ls 命令的手册页并获得有关命令输出的更多信息,但单个w" 每个文件的输出中的字符告诉我这些文件只能由文件所有者写入.这些文件都归 foo 用户所有(这是输出的第三列的意思).当我运行 Android Studio 时,我不是 foo,所以我无法写入这些文件,而且由于我不是 foo,我没有权限授予自己对它们的写访问权限.

If you run man ls you can read the man page for the ls command and get a lot more information on the output from the command, but the single "w" character in the output for each file tells me that those files are only writable by the file's owner. Those files are all owned by the foo user (which is what the third column of output means). I'm not foo when I'm running Android Studio, so I can't write to those files, and since I'm not foo, I don't have permissions to give myself write access to them.

您可以使用以下命令修复它.运行此命令时,请务必小心使用正确的路径;如果您犯了一个错误,在 sudo 下进行大规模的文件系统更改可能会造成很大的损害.

You can fix it with the following command. Be very careful you use the correct path when you run this command; making large-scale filesystem changes under sudo can do a lot of damage if you make a mistake.

sudo chown -R $USER /path/to/project/directory

可能有一种方法可以通过 Finder UI 解决此问题,但命令行非常简单.

There's probably a way to fix this through the Finder UI, but the command-line is pretty easy.

它会要求您输入管理员密码,然后它会让您成为这些文件的所有者,并且清除只读状态"对话框应该适合您.

It will ask you for an administrator password, and after that it should make you the owner of those files and the "Clear Read-Only Status" dialog should work for you.

这篇关于Android Studio 设置 - 清除只读状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆