P4EditVS icon indicating copy to clipboard operation
P4EditVS copied to clipboard

Open in P4V command does not use .p4config when Use Environment is selected

Open SimpsonGSD opened this issue 3 years ago • 4 comments

It's being reported that even though Use Environment is selected in one solution it is not using the .p4config file to get the correct P4 environment.

  • I tried a different solution, and it also crashed. Got an error message from perforce in the process: Path 'e:\perforce\new_solution\new_file.cpp/...' is not under client's root 'D:\dev\perforce\original_solution'. Both solutions have a .p4config set up, and Use Environment is true, so I guess the environment variables are pointing at original_solution or something? Shouldn't it use .p4config though?

Originally posted by @Malrog in https://github.com/SimpsonGSD/P4EditVS/issues/21#issuecomment-1054410103

SimpsonGSD avatar Feb 28 '22 19:02 SimpsonGSD

I suspect this was an issue with how I had p4v configured. In p4v Edit>Preferences I had the application launch set to "Restore all previously opened connections." So when the previous connections were to a different workspace (and sometimes even different server), this resulted in the issue reported above. Altering this setting to "Show connection dialog" allows me to pick the correct server + workspace, and that obviously works. Similarly, altering this setting to "Open the connection specified by your Perforce environment settings" also works - automatically opening to the correct server + workspace.

To fix this when Use Environment is selected you would probably need to extract the necessary p4 environment parameters to pass -p, -u and -c to your p4v call, which would then presumably override the setting in p4v.

Malrog avatar Mar 01 '22 10:03 Malrog

Hmm I would have thought that would only affect P4V (I could be wrong). Checkout commands, etc, use p4.exe and invokes the process from the working directory of the file that's being checked out. As long as p4config file is in that directory of one of the parent directories it should pick up the correct env vars.

Did you test checkout? Where is your p4 config file located relative to the file being checked out?

SimpsonGSD avatar Mar 01 '22 11:03 SimpsonGSD

It's just the "Open in Perforce" command (which runs p4v.exe) that is affected by this. Sorry if that wasn't clear. Everything else works fine.

Malrog avatar Mar 01 '22 11:03 Malrog

Ok that's good to know. I've updated the title to reflect it's for that command only.

One option is to use p4 set and get the variables to pass to P4V, as long as p4 set does not query the server and is a local operation only.

SimpsonGSD avatar Mar 01 '22 11:03 SimpsonGSD