0

I just created a new workspace. I am getting "Can't clobber writable file" error while doing p4 copy from a branch to another. Concerned file has been deleted on source branch. I did not touch concerned file. Even doing p4 sync -f before p4 copy command does not help. What could be issue ?

code707
  • 1,663
  • 1
  • 8
  • 20

2 Answers2

1

See How to fix Perforce error "Can't clobber writable file" or Perforce Error Message - Can't Clobber Writable File for more information on the "can't clobber" error in general.

In the specific case you describe where you just made a new workspace, my guess would be that you made the new workspace in a folder where files already existed locally (maybe on top of an existing workspace?). If you did create this workspace folder on top of an existing workspace, stop and pick a new root folder for this workspace; the other workspace won't "know" that its filesystem is being modified by the operations you do in this workspace, and when you switch back to that workspace everything is going to be bad (you might find that you've lost pending changes, sync won't be fetching the right thing unless you force-sync everything, et cetera).

If messing up another workspace isn't a concern, just do:

p4 clean

and once that's done your p4 copy should work.

Samwise
  • 68,105
  • 3
  • 30
  • 44
  • Yes, I created at same root. I don't care about old workspace. However my understanding was p4 sync -f should have solved the problem but it did not. I will try p4 clean, but curious to know how come p4 clean would solve while p4 sync -r could not – code707 Nov 05 '19 at 17:09
  • 1
    `p4 sync -f` only forces a re-sync of everything in the depot; it won't touch existing workspace files that don't have depot counterparts. `p4 clean` is specifically designed for the task you're doing; it will scan for "added" files and will also skip files that are already "in sync" whereas `p4 sync -f` will dumbly re-download everything even if it's already identical. See: https://web.archive.org/web/20150329004930/https://www.perforce.com/blog/140501/p4-clean-make-workspace-shine – Samwise Nov 05 '19 at 17:15
  • 1
    Make sure to `p4 client -d OLD_WORKSPACE` the old workspace spec if you're done with it, or you'll be setting yourself up for a confusing time a month from now when you accidentally switch to it. :) – Samwise Nov 05 '19 at 17:24
0

The file is writable on your local machine. p4 is trying to protect you from getting rid of a file you might have edited.

Since you say you created a new workspace, I'm assuming it contains the same root as your previous workspace. If you know you want to get rid of everything, you can manually delete those files and retry your p4 sync -f or the hand p4 refresh.

tkosinski
  • 1,631
  • 13
  • 17