Environment and registry variables
P4 Server has its own collection of forty-three environment and registry variables that allow you to specify a wide variety of things, such as the name of the client workspace, the location of the database journal and error logs, as well as to configure behavior, such as which files to exclude from version control, and which editor to bring up so you can edit forms.
A given environment variable might affect the server, the client, or both.
On this page:
Setting variables on the server
Most variables that affect the operation of the server can be set by a user with the super access level A permission assigned to a user to control which commands the user can run. See also the 'protections' entry in this glossary and the 'p4 protect' command in the P4 CLI Documentation. or an operator user by using the p4 configure command with this syntax:
p4 configure set variable=value
Linux example:
p4 configure set P4LOG=/opt/perforce//servers/server-name/logs/log
Windows example:
p4 configure set P4LOG=c:\perforce\servers\server-name\logs\log
Setting variables on the client
Some environment variables that affect only the client, such as P4EDITOR, can also be set by the end user. For example, on Windows:
p4 set P4EDITOR="C:\Program Files\Notepad++\notepad++.exe"
and on Linux:
export P4EDITOR=/usr/bin/nano
Use of P4CONFIG and/or P4ENVIRO can simplify the configuration of environment variables for clients.
Commonly used variables
P4ENVIRO stores environment variables (and Configurables) that are used across projects. For example, P4_port_CHARSET.
The file named by P4CONFIG in the current working directory (and its parent directories) define environment variables (and Configurables) that are used when working in that directory. For example, the combination of P4CLIENT, P4USER, and P4PORT. A user would typically set these so that a client applications, such as the P4 CLI and the P4 Visual Client (P4V) automatically use them. Otherwise, the user would have to specify them manually when starting a session.
Do not put P4 Server environment variables in the files named by P4CONFIG and P4ENVIRO because any server environment variables in those files are ignored.
System administrators typically set P4JOURNAL, P4LOG, P4PORT, and P4ROOT to define the environment that the server uses. An alternative is to write startup scripts.
Syntax for operating systems and shells
Suppose you want to set the target server with the P4TARGET environment variable.
-
On Linux for the Proxy server:
export P4TARGET=mainserver:1666 -
On Windows for the Proxy service:
p4 set -S "Perforce Proxy" P4TARGET=mainserver:1666
Suppose you want to set the P4CLIENT environment variable on
various command shells:
| Shell | Environment Variable Example | ||||
|---|---|---|---|---|---|
|
UNIX: bash, |
|
||||
|
UNIX: csh |
|
||||
|
Windows command shell or PowerShell |
Windows administrators running P4 Server as a service set the value of a variable:
For more details on setting
P4 Server
variables in Windows and macOS, see the |
Linux $home and Windows HOME
Many environment variables are set differently on Linux than on Windows.
On Linux, you can use $home to set environment variables. For
example:
P4IGNORE=$home/myignorefile
where $home is expanded to the path of the user’s home directory.
On Windows, the user’s home directory is the value of the
HOME environment variable or USERPROFILE.