简体   繁体   English

Perforce —取消链接许可在Mac OS X上被拒绝

[英]Perforce — unlink permission denied on Mac OS X

I'm trying to p4 sync , but I got a "Can't clobber writable file" error. 我正在尝试p4 sync ,但是出现“无法破坏可写文件”错误。 So, I removed the writable permission, but now I get this error: 因此,我删除了可写权限,但是现在出现此错误:

$ ls -l file.txt
-r--r--r--  1 myusername  admin   1.0K Jan 1 00:00 file.txt

$ p4 sync file.txt
//the/depot/directory/file.txt#5 - deleted as /my/local/workspace/directory/file.txt
unlink: /my/local/workspace/directory/file.txt: Permission denied

I am logged in as myusername . 我以myusername登录。 Why am I getting permission denied? 为什么我的权限被拒绝?

Instead of changing file permissions, you can do a p4 sync -f . 您可以执行p4 sync -f而不是更改文件许可权。 But take care, it can be dangerous: 但是请注意,这可能很危险:

Force the sync. 强制同步。 Perforce performs the sync even if the client workspace already has the file at the specified revision. 即使客户端工作区已经具有指定版本的文件,Perforce也会执行同步。 If the file is writable, it is overwritten. 如果文件可写,它将被覆盖。 This option does not affect open files, but it does override the noclobber client option. 此选项不会影响打开的文件,但会覆盖noclobber客户端选项。

So make sure to commit your work before doing it. 因此,请确保在执行之前提交您的工作。

Why am I getting permission denied? 为什么我的权限被拒绝?

Because you just took away your own write permission. 因为您只是拿走了自己的写权限。 That means you no longer have permission to write to the file. 这意味着您不再具有写入文件的权限。 Which means p4, acting on your behalf, no longer has permission to write to the file. 这意味着p4(代表您执行操作)不再具有写入文件的权限。 Which means that when p4, acting on your behalf, asks for permission to write to the file, it's denied. 这意味着,当p4代表您执行操作时,请求写入文件的权限被拒绝。 Which means p4 says "Permission denied". 这意味着p4会显示“权限被拒绝”。

What else did you expect to happen? 您还期望发生什么?

The reason p4 sync is complaining is that you appear to have a file that you've checked out (and therefore possibly made changes to) and it doesn't know about it, so it refuses to just overwrite your hard work. p4 sync抱怨的原因是,您似乎有一个已签出(因此可能进行了更改)的文件,而它对此一无所知,因此它拒绝仅覆盖您的辛苦工作。 You should manually revert the file, if that's what you want to do. 如果您要这样做,则应该手动还原文件。

Perforce keeps track of what state it expects your files to be in. If it left a file with non-writable access, and expects it to still be in that state, it will attempt to chmod it before overwriting it. Perforce会跟踪期望文件处于什么状态。如果它使文件具有不可写访问权限,并希望它仍处于该状态,它将在覆盖之前尝试对其进行chmod操作。 But if it thinks the file should be writable, it will just open it and try to write it. 但是,如果它认为该文件可写,则将其打开并尝试写入。 The fact that a chmod would succeed is irrelevant if p4 never calls it. 如果p4从不调用chmod,则chmod成功的事实无关紧要。

At any rate, the solution is to explicitly revert the file, delete it and re-pull it, etc. 无论如何,解决方案是显式还原文件,删除并重新拉动文件等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM