I have a file that shows up in various views via p4v and via ls
but when I go to its directory in my client and do p4 edit thefile
It says thefile - file(s) not on client
I don't understand why, if the file shows up in ls
, the p4
command can give that answer, because everything that is written about "clients" seems to say that the client is a path within my SSD where files are physically present.
p4 client
has a section called view and the only mapping there basically maps the whole world to certain directory like //WORLD/... //client/... so this can't be the issue.
Help me decode "file(s) not on client"
The client is defined in part by a set of mappings between the depot and your local workspace, but it's more than that -- it's also a set of metadata stored in the server database that tracks the relationship between what's in your workspace and what's in the depot. When you sync
a file, the server writes the file to a location in your workspace according to the client view, and it writes a record in its metadata that says "the client has this depot revision at this location". Tracking this relationship in the metadata is an optimization that's key to Perforce's performance at large scales; as long as it can determine what's on your client with a simple database lookup, it doesn't need to go and ping the client and checksum all of its files in the course of routine operations.
If you get the message file(s) not on client
, it means that according to the server's metadata, your client does not have this file. (If the file isn't in your view, I'd expect you to get an error more like file(s) not in client view
.) Some commands you might want to run to verify the state of the file:
p4 have thefile
-- what revision of this file does the server think I have
? (I predict this will also return "not on client".)p4 add -n thefile
-- what if I were to try to add
this file to the depot?p4 sync -n thefile
-- what if I were to try to sync
this file from the depot?If p4 sync
says there's nothing to sync, then what you probably want to do is p4 add
the file (i.e. just run p4 add thefile
without the -n
).
If some revision of the file already exists in the depot at that path, then p4 add
will say can't add existing file
-- what you probably want to do instead is reconcile whatever you have in your workspace with the depot file. To do that, you can tell the server "sync
this file but k
eep my workspace version, and then reconcile
what's in the workspace vs what you think I have." That looks like this:
p4 sync -k thefile
p4 reconcile thefile
If p4 reconcile
says "no files to reconcile", it means that your workspace file is already identical to what's in the depot. At this point you can go ahead and p4 edit
it and continue working.
If p4 reconcile
says "opened for edit", it means your file is already different from what's in the depot, and it's now opened for edit so you can decide what to do with the changes. Run p4 diff
to see. Be careful -- if your workspace file is an older version of the depot file, submitting it as-is will roll back the newer changes! (You'd see this reflected in the diff
output, probably in the form of a bunch of lines being removed.) If that's the case you might want to p4 revert
the file and start from a clean slate.
The tl;dr recommendation is: use p4 sync
to pull files from the depot into your workspace. Do not manually copy files into your workspace, because Perforce works best when it's able to track everything that happens in your workspace.