{"id":51,"date":"2009-11-02T23:57:01","date_gmt":"2009-11-03T03:57:01","guid":{"rendered":"http:\/\/adamrosenfield.com\/blog\/?p=51"},"modified":"2009-12-21T01:21:31","modified_gmt":"2009-12-21T05:21:31","slug":"making-p4-and-cygwin-play-nice","status":"publish","type":"post","link":"http:\/\/adamrosenfield.com\/blog\/2009\/11\/02\/making-p4-and-cygwin-play-nice\/","title":{"rendered":"Making p4 and Cygwin play nice"},"content":{"rendered":"<p>Say you&#8217;re a developer doing development on Windows, and say you&#8217;re using <a href=\"http:\/\/www.perforce.com\">Perforce<\/a> (better known as p4) for source control.  Let&#8217;s also say you have *nix background and like using <a href=\"http:\/\/www.cygwin.com\">Cygwin<\/a> to keep you from going insane.  What are your options for interacting with p4?<\/p>\n<p>Fortunately, Perforce provides a binary compiled against Cygwin.  You can download that, drop it in your <code>$PATH<\/code>, and be on your merry way.<\/p>\n<p>But I happen to like <a href=\"http:\/\/www.perforce.com\/perforce\/products\/p4win.html\">P4Win<\/a> as a graphical client, and P4Win doesn&#8217;t play nicely with the Cygwin p4.  Why?  Client roots.  With P4Win (or any other non-Cygwin client, for that matter), your client root is a Windows-style path, e.g. <code>C:\\path\\to\\root<\/code>.  But Cygwin sees things differently.  It wants your client root to be something like <code>\/cygdrive\/c\/path\/to\/root<\/code>.<\/p>\n<p>So, if you have a client set up with P4Win and try to interact with the command line p4 in Cygwin, you&#8217;ll get messages like this:<\/p>\n<pre>'awesomecode.cc' is not under client's root 'C:\\path\\to\\root'<\/pre>\n<p>You can get around this by using absolute paths, e.g.:<\/p>\n<pre>p4 edit $(cygpath -wa awesomecode.cc)<\/pre>\n<p>That gets tiresome very fast, though.  But you, fearless reader, you are in luck!  I have just the solution for you!  It turns out that all p4 needs is a little persuasion to change its <code>PWD<\/code> environment variable.  I whipped up a little C program that fixes up its <code>PWD<\/code> and exec&#8217;s the real p4, so it no longer gets confused.<\/p>\n<p>You can download my program <a href=\"http:\/\/adamrosenfield.com\/files\/p4.zip\">here<\/a>.  Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Say you&#8217;re a developer doing development on Windows, and say you&#8217;re using Perforce (better known as p4) for source control. Let&#8217;s also say you have *nix background and like using Cygwin to keep you from going insane. What are your options for interacting with p4? Fortunately, Perforce provides a binary compiled against Cygwin. You can [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-tools"],"_links":{"self":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":5,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":57,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/posts\/51\/revisions\/57"}],"wp:attachment":[{"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/adamrosenfield.com\/blog\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}