10 messages in com.perforce.p4ruby[p4ruby] fix for symlink-in-PWD problem
FromSent OnAttachments
bob p406 Mar 2008 06:29 
Tony Smith07 Mar 2008 05:45 
bob p407 Mar 2008 11:36 
Tony Smith10 Mar 2008 07:25 
Tony Smith10 Mar 2008 07:31 
bob p410 Mar 2008 08:59 
Tony Smith10 Mar 2008 09:54 
bob p410 Mar 2008 11:10 
Tony Smith11 Mar 2008 04:28 
bob p411 Mar 2008 16:51 
Subject:[p4ruby] fix for symlink-in-PWD problem
From:bob p4 (jeff@gmail.com)
Date:03/06/2008 06:29:01 AM
List:com.perforce.p4ruby

[ In reference to http://maillist.perforce.com/pipermail/p4ruby/2008q1/000115.html ]

I finally got P4Win cooperating with cygwin-p4ruby via listing my cygwin path in AltRoots, however I ran into a bit of confusion along the way. My client root is /home/me/some/long/path, which I have symlinked to /home/me/work. Apparently this causes a glitch since the shell sets PWD to /home/me/work instead of the full path:

http://kb.perforce.com/UserTasks/ConfiguringP4/SymbolicLinks

Note the Perforce authors decided not to solve the problem: "However, this doesn't necessarily fix the issue of symlinks under the Perforce client root. For that, you will still need to either set and export the $PWD environment variable, or use the -d argument as necessary."

May I suggest the following patch to workaround it:

require 'p4' require 'pathname'

class P4 class << self alias_method :previous_new, :new def new(*args, &block) previous_pwd = ENV["PWD"] begin ENV["PWD"] = Pathname.new(previous_pwd).realpath previous_new(*args, &block) ensure ENV["PWD"] = previous_pwd end end end end

I am using p4ruby-2007.3 with cygwin p4api-2007.3.143793.

IMO Perforce should expand away the symlink, but until then at least P4Ruby can do it. Please spare others from this needless pain!