How to set client root in Perforce P4 when client unknown error comes
Asked Answered
S

5

13

Suddenly, when I run p4 info in terminal, I notice that the client root is not set (not sure why it got unset all of a sudden. Following is the output which shows "client unknown" in place of client root. What is the command through which I can set the same? I have tried p4 client and p4 set but may be, with wrong syntaxes.

BANL121b92746:Applications bagarwal2$ p4 info
User name: bagarwal2
Client name: BANL121b92746
Client host: BANL121b92746.local
Client unknown.
Current directory: /Applications

And is the value of this client root be the same as "Workspace Root" set in my P4V client under Connections->Edit Workspace . My P4V client is working perfectly. I found this problem with p4 info when my Intellij IDEA started showing connection problems in P4. On testing the connection in IDEA, below is the error screenshot, which is same as when I do p4 info in terminal.

enter image description here

Regarding my p4settings.txt config, below are the configs which were working for months till now:

P4HOST=<hidden hostname>:2500
P4CLIENT=bagarwal2_BANL121b92746_trunk
P4USER=bagarwal2
P4POST=<hidden hostname>:2500

My P4V connection (which works all fine), uses the same details/config which are mentioned above, still I find this problem in terminal and hence in Intellij IDEA.

Slurp answered 12/10, 2015 at 7:38 Comment(2)
Try running "show connection info" in P4V and pasting the results of that. Essentially you want "p4 info" to match that -- if we can see that we can tell you what "p4 set" commands to run to make it match. All you should need to do is set P4PORT, P4USER, and P4CLIENT.Clinch
Hi Sam, I have edited the question and added some details. I notice that I don't add P4PORT explicitly, I remember it was not required till now when it was working. Also, in P4V, I was unable to find "show connection info", I found "Connection -> Open Connection" menu from which I confirmed that the values are correct and match with those set here. I also tried adding "P4PORT=2500" or "P4PORT=<hidden hostname>:2500" in p4settings.txt and the error changed from "client unknown" to "Not connected".Slurp
C
9

It looks like your p4settings.txt config file isn't being used; otherwise the client name returned by "p4 info" would match the P4CLIENT value in the config file. Run:

p4 set P4CONFIG=p4settings.txt

and make sure that when you run "p4 info" you're doing it from a directory underneath ~/dev/trunk. (Your "p4 info" output in the question shows your current directory as /Applications, so that might explain the problem on its own -- just do "cd ~/dev/trunk" and try again.)

The "client unknown" error suggests that maybe your client spec got deleted (this is assuming you're connecting to the same server and using the same client name you were successfully using before). If that's what happened you can create a new one with the same name by running:

p4 client
Clinch answered 12/10, 2015 at 8:23 Comment(9)
Thanks Sam. I tried the command but still it shows the same error "client unknown" for the root. Doesn't this command sets only the client name and not the root? The reason I am asking is the name is already set in my case.Slurp
BTW, I tried with both the workspace name and workspace name with full absolute path.Slurp
The "workspace name" isn't a filesystem path, so if you're using a "full absolute path" you're not setting the workspace name. The root is stored in the server database and associated with the client (workspace) name, so if you connect to the right server (P4PORT) with the right client (P4CLIENT) all the other information is remembered automatically.Clinch
Edited to be more useful in light of the new information.Clinch
Thanks Sam. I tried the suggestion, but unfortunately,didn't help. Also, client in p4settings.txt and by using "p4 info" under trunk directory is same, i.e. "bagarwal2_BANL121b92746_trunk"... Let me paste what I did: BANL121b92746:trunk bagarwal2$ echo $P4CONFIG p4settings.txt BANL121b92746:trunk bagarwal2$ p4 set P4CONFIG=p4settings.txt Perforce client warning: Warning: environment variable hides registry definition of P4CONFIG. BANL121b92746:trunk bagarwal2$ p4 info User name: bagarwal2 Client name: bagarwal2_BANL121b92746_trunk Client unknown. Current directory: /Users/bagarwal2/dev/trunkSlurp
Since you're hiding the P4PORT setting I can't be absolutely sure that you aren't connecting to the wrong server, but if the server is correct and the client name is correct, the only remaining explanation is that your client spec got deleted. Run "p4 client" to recreate it.Clinch
Thanks. The problem is solved now. I had to set P4CLIENT in my bash_profile "export P4CLIENT=${USER}_BANL121b92746_trunk" and it worked, both in terminal and Intellij Idea afterwards. Thanks for all the support.Slurp
I also had the exact same problem under Windows: p4v worked just fine, but running commands e.g. p4 clean from the command line failed with the Client '<My_computer_name>' unknown - use 'client' command to create it. error. The very last line of @SamStafford 's reply fixed it - a pre-populated client spec opened in an editor, no need to change anything, just save it back and exit, and things were solved. In my case I very strongly suspect the cause was a "repair" of Windows I'd done very recently.Palpitate
Another possible reason for you to suddenly get "client unknown" errors would be that your hostname got changed when you reinstalled Windows (the client hostname is the default P4CLIENT value). If you explicitly set P4CLIENT and/or P4HOST you won't have this problem.Clinch
C
11

Try p4 set p4client=my_client.

This stores your preferred client in the registry. There are other ways to set your client, with different precedence and scope:

  • environment variables (potentially different per process)
  • P4CONFIG files (potentially different per filesystem location)
  • command-line options (potentially different for every invocation of p4.exe)

but for simplicity, using p4 set is all you should need.

BTW, P4V uses its own setting (there's a dialog that comes up by default when you start P4V).

Cellist answered 12/10, 2015 at 8:24 Comment(7)
Thanks. I tried the command but still it shows the same error "client unknown" for the root. I tried with both the workspace name and workspace name with full absolute path. Doesn't this command sets only the client name and not the root? The reason I am asking is the name is already set in my case.Slurp
The root is an attribute of the client. To set it up, use P4V, View > Workspaces > find it by name (BANL121b92746) > right click and choose Edit > set its Workspace root. If it's already set then you're good to go. (But then I'm not sure what it is that's not working for you.)Cellist
Thanks again. Both- workspace name and the root is set correctly in P4V and P4V client is working perfectly fine. It is the p4 install whose info I am checking by typing "p4 info" in terminal, which I think is faulty. I came to know about it when suddenly my Intellij IDE started complaining of this by popping "client unknown" error while checking out P4 files.Slurp
Why do you think that IntelliJ is failing due to the "Client root" missing in p4 info? Is this documented somewhere that IDEA uses p4 info for this? (I'd be quite surprised if it did.) Also, to me "client unknown" means "client name unknown" (as in client unset), not "client root unknown".Cellist
Hi, I just added some more details to the question. I assume my Intellij to be failing with this reason because I have set p4 executable in IDEA to "/Applications/p4" and not to any Intellij installed p4 + the same issue comes in both - IDEA and terminal. May be it will not call "p4 info" per se, but, it is definitely a connection problem which I don't know how to resolve and in the first place, how can something like this come all of a sudden when it working smoothly for months now.Slurp
Your p4 info reports client "BANL121b92746" while your P4CONFIG seems to set "bagarwal2_BANL121b92746_trunk". Which is the client you want to use? Are you sure both of these actually exist? (Check the output of p4 client -o CLIENTNAME.)Cellist
Thanks. The problem is solved now. I had to set P4CLIENT in my bash_profile "export P4CLIENT=${USER}_BANL121b92746_trunk" and it worked, both in terminal and Intellij Idea afterwards. Thanks for all the support.Slurp
C
9

It looks like your p4settings.txt config file isn't being used; otherwise the client name returned by "p4 info" would match the P4CLIENT value in the config file. Run:

p4 set P4CONFIG=p4settings.txt

and make sure that when you run "p4 info" you're doing it from a directory underneath ~/dev/trunk. (Your "p4 info" output in the question shows your current directory as /Applications, so that might explain the problem on its own -- just do "cd ~/dev/trunk" and try again.)

The "client unknown" error suggests that maybe your client spec got deleted (this is assuming you're connecting to the same server and using the same client name you were successfully using before). If that's what happened you can create a new one with the same name by running:

p4 client
Clinch answered 12/10, 2015 at 8:23 Comment(9)
Thanks Sam. I tried the command but still it shows the same error "client unknown" for the root. Doesn't this command sets only the client name and not the root? The reason I am asking is the name is already set in my case.Slurp
BTW, I tried with both the workspace name and workspace name with full absolute path.Slurp
The "workspace name" isn't a filesystem path, so if you're using a "full absolute path" you're not setting the workspace name. The root is stored in the server database and associated with the client (workspace) name, so if you connect to the right server (P4PORT) with the right client (P4CLIENT) all the other information is remembered automatically.Clinch
Edited to be more useful in light of the new information.Clinch
Thanks Sam. I tried the suggestion, but unfortunately,didn't help. Also, client in p4settings.txt and by using "p4 info" under trunk directory is same, i.e. "bagarwal2_BANL121b92746_trunk"... Let me paste what I did: BANL121b92746:trunk bagarwal2$ echo $P4CONFIG p4settings.txt BANL121b92746:trunk bagarwal2$ p4 set P4CONFIG=p4settings.txt Perforce client warning: Warning: environment variable hides registry definition of P4CONFIG. BANL121b92746:trunk bagarwal2$ p4 info User name: bagarwal2 Client name: bagarwal2_BANL121b92746_trunk Client unknown. Current directory: /Users/bagarwal2/dev/trunkSlurp
Since you're hiding the P4PORT setting I can't be absolutely sure that you aren't connecting to the wrong server, but if the server is correct and the client name is correct, the only remaining explanation is that your client spec got deleted. Run "p4 client" to recreate it.Clinch
Thanks. The problem is solved now. I had to set P4CLIENT in my bash_profile "export P4CLIENT=${USER}_BANL121b92746_trunk" and it worked, both in terminal and Intellij Idea afterwards. Thanks for all the support.Slurp
I also had the exact same problem under Windows: p4v worked just fine, but running commands e.g. p4 clean from the command line failed with the Client '<My_computer_name>' unknown - use 'client' command to create it. error. The very last line of @SamStafford 's reply fixed it - a pre-populated client spec opened in an editor, no need to change anything, just save it back and exit, and things were solved. In my case I very strongly suspect the cause was a "repair" of Windows I'd done very recently.Palpitate
Another possible reason for you to suddenly get "client unknown" errors would be that your hostname got changed when you reinstalled Windows (the client hostname is the default P4CLIENT value). If you explicitly set P4CLIENT and/or P4HOST you won't have this problem.Clinch
J
0

UNIX: bash, ksh, sh,

P4CLIENT=value ; export P4CLIENT

UNIX: csh

setenv P4CLIENT value

Mac OS X (bash)

P4CLIENT=value ; export P4CLIENT

Windows

p4 set P4CLIENT=value

Windows administrators running Helix Server as a service can set variables for use by a specific service with p4 set -S svcnamevar=value, or set variables for all users on the local machine with p4 set -s var=value.

More details here: https://www.perforce.com/manuals/cmdref/Content/CmdRef/envars.html

Jody answered 25/3, 2019 at 14:59 Comment(0)
H
0

SET P4PORT in the environment variable. then when you try P4 info client unknown error will be gone & it will show the p4root value which is set in perforce. It worked for me.

Hexaemeron answered 15/4, 2020 at 12:29 Comment(0)
N
0

I ran into this issue, and come to find out the perforce registry keys under Computer\HKEY_CURRENT_USER\SOFTWARE\Perforce\Environment are case sensitive! Somehow, someway, the P4CLIENT key was set to p4client. Setting it to upper case and then running p4 client command solved the issue for me.

Nook answered 26/8, 2022 at 0:36 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.