Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Summary: The Perforce command line p4 does not work correctly unless I open the shell from P4V. How/where do I edit things to fix my configuration so that it always works?


On Windows 7x64, if I run cmd.exe and then use the p4 command line it attempts to connect to an old server that no longer exists:

C:\>p4 info
Perforce client error:
        Connect to server failed; check $P4PORT.
        TCP connect to p4proxy-bdr:2006 failed.
        connect: p4proxy-bdr:2006: WSAETIMEDOUT

C:\>echo %P4PORT%

However, if I launch P4V (which is connecting to the correct server), right-click on any file in my Workspace and choose "Open Command Window Here", the same commands work correctly:

C:\>p4 info
User name: gkistner
Client name: gkistner-dt2
Client host: gkistner-dt2
Client root: C:/p4/p4sw
Current directory: c:\
Peer address: <redacted>
Client address: <redacted>
Server address: <redacted>
Server root: <redacted>
Server date: 2013/08/13 10:05:09 -0700 PDT
Server uptime: 1512:04:23
Server version: <redacted>
Server license: <redacted>
Server license-ip: <redacted>
Case Handling: sensitive

C:\>echo %P4PORT%

Where is P4 getting the configuration when I launch it from a vanilla cmd.exe, and how do I change that to be the same as what P4V sets up?

share|improve this question
Related: – Phrogz Aug 13 '13 at 18:01

P4's command line settings can be set by using the p4 set command. With no arguments, under the working shell, this lists the current values:

C:\>p4 set
P4EDITOR=C:\Windows\SysWOW64\notepad.exe (set)
P4PASSWD=<redacted> (set)

Then, go to the non-working shell and copy/paste each of these, prefixed with p4 set:

C:\>p4 set P4CLIENT=gkistner-dt2
C:\>p4 set P4EDITOR=C:\Windows\SysWOW64\notepad.exe
C:\>p4 set P4PASSWD=<redacted>
C:\>p4 set P4PORT=p4sw:2006
C:\>p4 set P4USER=gkistner

Now you can close this shell and open any new one, and P4 will work.

share|improve this answer

The approach I use is as follows:

1 All global perforce settings I set through environmental variables:

P4EDITOR=C:\Program Files (x86)\Vim\vim74\gvim.exe

2 Tell perforce that specific client's configuration is stored in .p4config file located in the root folder of the client's view. This is done through an environmental variable too:


3 Then in each client's root folder I create a .p4config file and set there the specific client's configurations as follows:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .