Perforce Public Knowledge Base - Choosing between AltRoots
Reset Search
 

 

Article

Choosing between AltRoots

« Go Back

Information

 
Problem

I use the AltRoots field in my client specification so that I can share my workspace between my Windows and Linux/UNIX computers. Occasionally, p4 incorrectly determines the client root directory.

How does the Perforce Command-Line Client decide which client root to use?


Solution

If you specify AltRoots, the Perforce Command-Line Client chooses the client root based on where you execute your p4 command. Perforce compares the current working directory against the Root first, and then against the alternate client workspace roots, if present. The first root to match the current working directory is used. If no roots match, the main root is used.

If you use alternate client workspace roots, ensure that you configure your client correctly:

  • Since the client can be used from multiple hosts, normally you need to remove the Host field from your client workspace form.
  • Specify one or two entries for the AltRoots field. If you are using a Windows directory in any of your client roots, specify the Windows directory as your Root and specify your other workspace root directories in the AltRoots field.
For example:
Client:   p_ws
[...]
Host:     some-vm  <=======  remove this field 
Root:     c:\my_ws
AltRoots: /Users/bruno/client/test/
[... remainder of client spec ...]
  • If you specify two directories for the AltRoots field, enter the second on a separate line, indented with one or more spaces or tabs
To confirm that your client workspace root is selected correctly on Windows and on Linux/UNIX:
  1. Log into a Windows host and run p4 where //p_ws/.... The output should resemble this:
    C:\my_ws>p4 where //p_ws/...
    //depot/... //p_ws/depot/... c:\my_ws\depot\...
    //apps/... //p_ws/apps/... c:\my_ws\apps\...
    
    
  2. Log into a Linux/UNIX host and run p4 where //p_ws/.... The output should resemble this:
    $ p4 where //p_ws/...
    //depot/... //p_ws/depot/... /Users/bruno/client/test/depot/...
    //apps/... //p_ws/apps/... /Users/bruno/client/test/apps/...
    
As an alternative to AltRoots, or if p4 where does not choose the client workspace root that you expect, you can use the -d  global option to specify the working path on your p4 commands. For example:

p4 -d /some/root/directory/ <command>
Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255