Editor P4CONFIG

It appears that the Revision Control setting for Perforce to Use P4 Config doesn’t actually read the config file.

I have my environment variable P4CONFIG=.p4config. When I open Revision Control in the editor and check this box it uses defaults like my computer username, computer name as the workspace and perforce:1666 as the server even though my .p4config has these values set in the root project directory.

Opening a command prompt and CD’ing into the project root directory then running p4 set will show the config file loaded properly.

Has anyone been able to use a p4config file with UE5.3?

4 Likes

just so you know. you’re not alone.

same problem with 5.2 / 5.3

1 Like

I have the same problem. However, if you have one single project, you might be fine with setting the variables you define in the config manually, making them work globally.

p4 set p4client=myworkspace
p4 set p4user=mynickname
p4 set p4port=ip:port

Setting the variables in the registry works. The part we can’t get to work is to have the “Use P4CONFIG” checked on as default in the project settings, so that when other users pull the .uproject down from the depot, this is already set. If anyone knows how to do that, I’d love to know.

Sharing here in case anyone else has this same issue. Been debugging this issue for a while, turns out it has more to do with the P4V client itself rather than P4 or UE.

The “Use P4 Config” option hints the issue is likely due to the enviroment variables itself.

Even if the “p4 set” cmd is displaying the correct info, verify if this is also reflected in P4V by going to:

“Connection” tab > “Enviroment Settings…” > observe the enviroment information.

If you’re seeing the default fields (e.g. P4PORT=perforce:1666), unselect the checkbox for “Use current connection for enviroment settings”, then click OK. Optionally, you may select your current connection settings.

image

Now if you reopen “Enviroment Settings”, you’ll see the checkbox is re-enabled automatically & the correct information is populated according to your P4+.p4config.txt settings.

verify if the UE GUI option for “Use P4 Config” works now (restart PC if it’s throwing error).

Presumably, this process helps to unset any previous/default values so P4V can parse the correct enviroment infromation from “.p4config.txt” properly.

What’s interesting is Rider doesn’t have this same issue reading from “.p4config.txt” while using its cvs-perforce ide integration. I’m assuming Rider pulls its enviroment data directly from P4, while UE pulls from P4V (which itself parses from P4).

Edit: Unless you only have a single workspace, this is only a partial solution; you’ll need to repeat this process whenever you need to switch workspaces.

1 Like

By adding [YourProject]\Saved\Config\WindowsEditor\SourceControlSettings.ini to Perforce, it should be automatically setup.

Just keep inside

[PerforceSourceControl.PerforceSourceControlSettings]
UseP4Config=True

[SourceControl.SourceControlSettings]
Provider=Perforce

I have encountered this problem too.

From my observation, the current path in Unreal is the engine directory (or base dir)

Inside Unreal you can check the current Path in Python

import os
current_path = os.getcwd()
print("Current working directory:", current_path)

LogPython: Current working directory: C:\Program Files\Epic Games\UE_5.3\Engine\Binaries\Win64

So your p4config.txt will never be taken into account by Unreal as your outside of your depot!

For the moment, I have made a Python script to change to current directory but I have to uncheck/check the “Use P4 Config” manually to take into account the p4config file.

The only way I know to disconnect/reconnect the source control is with the help C++.

I have tried to bypass this, by forcing the lauching path of Unreal from the project directory with a batch file, it’s not working.

For me it has to be done somewhere inside Unreal.