20

So, virtually cannot use the the perforce command line for anything other than syncing. My workspace root is mapped to C:\ Here's a line of my client spec: //claims1.0/main/... //cthiel/code/claims1.0/main/...

Any time I fire up cygwin and attempt to work with any files in my depot (such as p4 edit ), I get an error along the lines of: Path '/cygdrive/c/code/commonTest/main.p4ignore' is not under client's root 'C:\'.

The paths aren't matching up, because the equivalent of C:\ for cygwyn is /cygdrive/c. So it's never able to find files with the perforce command line.

Is there a way to fix this? It's highly annoying.

bergyman
  • 4,480
  • 3
  • 23
  • 32

6 Answers6

35

Found a solution:
Add this to your .bashrc:

function p4() {
export PWD=`cygpath -wa .`
/cygdrive/c/Program\ Files/Perforce/p4.exe $@
}

Works like a charm for me.

bergyman
  • 4,480
  • 3
  • 23
  • 32
  • I found this preferable to the cygwin p4 client for some reason. Probably my own lack of knowledge - I found that the cygwin binary required me to set a password via environment variable (always yucky to see env variables with sensitive data), and even still I got the same error. This worked magically. – Eddie Parker Aug 17 '10 at 17:22
  • You are a life-saver. PWD was the issue in my script, because I had mapped my %TEMP% as /tmp :-) – anishsane Apr 26 '13 at 09:55
  • 3
    I found that *not* exporting PWD is better because changing $PWD can mess up emacs and also changes bash prompt to windows format. I prefer doing this: function p4() {PWD=`cygpath -ma .` "`which p4`" $@}. This way PWD is only changed inside the p4 command. – dividebyzero Mar 28 '14 at 14:02
  • To extend the fix to scripts/subshells, add this after the alias: `export -f p4` Background: https://stackoverflow.com/questions/4471364/how-do-i-list-the-functions-defined-in-my-shell https://unix.stackexchange.com/questions/427946/bash-script-is-not-inheriting-its-parents-env – Samuel Sep 30 '19 at 20:17
11

Even mo' betta':
Use the cygwin p4 client: http://filehost.perforce.com/perforce/r07.2/bin.cygwinx86/p4.exe

Just make sure this is in your path before the Perforce/p4.exe. Et voila.

bergyman
  • 4,480
  • 3
  • 23
  • 32
  • this version this link points to is obviously not the latest/greatest, but the other versions are also available in sibling directories. – Mike Ellery Aug 05 '10 at 21:08
  • 4
    You can get the latest client from here: http://www.perforce.com/downloads/complete_list Click on "Other" and then "cygwin" – Philip Sep 16 '11 at 20:59
  • 1
    the latest cygwin perforce client worked for me, thanks Phillip! I was having trouble with P4CONFIG being "ignored" under cygwin when using the NTX86 2008 client. The problem doesn't occur with the 2010 and 2011 NTX86 p4.exe clients. – Bogatyr Feb 15 '12 at 14:23
  • It didn't work for me. I know I'm invoking the correct p4 but it simply does nothing, prints nothing... For now I'm sticking with the previous solution. – Chuim Dec 03 '13 at 19:48
  • 2
    Perforce's web site reports that their [Cygwin-native client was discontinued May 2013](http://perforce.com/downloads/complete_list/archived/archived_perforce_platform?qt-others=1#qt-others). – Jay Baxter Feb 18 '14 at 23:36
5

You can setup altroots in your client spec, that might cover this?

Although the cygwin p4 is the solution I'd go for. But I would go for the latest version: http://filehost.perforce.com/perforce/r09.2/bin.cygwinx86/p4.exe - it'll work with any older server, but will have fewer bugs.

Douglas Leeder
  • 52,368
  • 9
  • 94
  • 137
4

Please note, the Perforce CLI client for CygWin has been deprecated and will be no longer supported after 5/1/2013, according to the Perforce web site. There is discussion of this topic at the Perforce support forums, including a poll which attempts to gauge the level of interest in continuing support for the CygWin client. Support is being discontinued for financial reasons (license fees to Redhat for commercial Cygwin distribution); so if sufficient interest is shown, that decision may be reconsidered.

If you use the P4 Cygwin client, ever have, or have any interest in the subject, I urge you to participate in the poll. Thanks.

Codex24
  • 323
  • 1
  • 5
  • 14
1

A modified version of the .bashrc function to avoid the cygpath overhead and finding p4.exe executable in the PATH automatically:

function p4() {
    PWD= `which p4` "$@"
}
Earl
  • 181
  • 4
0

Alt root seems to work fine for me. However I am not using cygwin. My source code resides in linux server and I have client in windows machine. I have mapped server's workspace on windows using network drive.

Kunal
  • 3,475
  • 21
  • 14