git-p4 submit fails with 'Path is not under client's root' error

3.1k views Asked by At

I've configured git mirror of perforce repository via git-p4 as described in http://answers.perforce.com/articles/KB_Article/Git-P4 and worked fine for some time: I was able to get perforce changes into git and to submit git changes to perforce. Then suddenly the git p4 submit command stopped working. When I run it, I get an error:

You have files opened with perforce! Close them before starting the sync.

When I run it in verbose mode it shows that the p4 -c <client name> -G opened ... command fails with the following output:

{scodeserrorsdatasrPath '/path/to/git/clone/...' is not under client's root '/path/to/git-p4-area'.
severityisgenerici0%

Well, it is indeed not under /path/to/git-p4-area but that wasn't a problem before. Also I still can run git p4 rebase without any problems. How do I fix the Path is not under client's root error?

Update

I was able to solve it thanks to Bryan's answer. It turns out the error I got was correct, I indeed had files opened in perforce. I've reverted them with the p4 revert ... command inside /path/to/git-p4-area and now git p4 submit works fine.

The error confused me because when you use git-p4, you don't change files in a perforce workspace, instead you work with a git repository and git-p4 translates git commits into perforce changes and vice versa. Turns out my perforce ticket expired in the middle of last submit operation (the ticket expires every 12 hours). So some files were left opened in a perforce workspace. The best fix would be to work less than 12 hours...

2

There are 2 answers

1
Bryan Pendleton On

The client root tells the Perforce server where your copy of the files are stored on your workstation or laptop. Perhaps you copied or renamed or moved that folder on your workstation?

If you did unintentionally move or rename the folder, you could move it back to where the server expects it to be.

Or, you could use the 'p4 client' command to update your client root so that the Perforce server knows where the files are stored on your workstation

0
ulidtko On

This was the solution for me:

$ p4 opened -s | awk '{print $1}' | xargs p4 revert

... because p4 opened output was (surprisingly) not empty.

After that, the usual git p4 submit succeeded.