Environment and registry variables
P4 Server has its own collection of 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.
-
Which files to exclude from version control.
-
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:
Set 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
For example, on Linux:
p4 configure set P4LOG=/opt/perforce//servers/server-name/logs/log
For example, on Windows:
p4 configure set P4LOG=c:\perforce\servers\server-name\logs\log
Set 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 Linux:
export P4EDITOR=/usr/bin/nano
For example, on Windows:
p4 set P4EDITOR="C:\Program Files\Notepad++\notepad++.exe"
Using 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) defines 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 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.
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
The syntax for setting environment variables depends on your operating system. For example, suppose you want to set the target server with the P4TARGET environment variable:
-
On Linux, for the Proxy server, use
export P4TARGET=mainserver:1666 -
On Windows, for the Proxy service, use
p4 set -S "Perforce Proxy" P4TARGET=mainserver:1666
The syntax for setting environment variables also depends on your shell. For example, suppose you want to set the P4CLIENT environment variable. The required syntax for different shells is outlined in the following table.
| Shell | 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 the specified service, use this syntax:
For example, p4 set -S Perforce P4LOG="log" where For all users on the local machine, use this syntax: p4 set -s var=value For example, p4 set -s P4PORT=ssl:myhost:1667 where users connect on port 1667. For more details on setting
P4 Server
variables in Windows and macOS, see the |
Linux $home and Windows HOME
You can use a user's home directory when setting environment variables.
On Linux, you can use $home, which expands to the path of the user’s home
directory. For example:
P4IGNORE=$home/myignorefile
On Windows, the user’s home directory is the value of the
HOME environment variable or USERPROFILE.