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:Tony Smith (to@smee.org)
Date:03/07/2008 05:45:48 AM
List:com.perforce.p4ruby

The easier workaround is:

ENV.delete( "PWD" )

If PWD isn't present in the environment, then the Perforce API will fall back on using the result of getcwd(), which expands your symlink as required.

Note that the PWD environment variable is intended to supress expansion of symlinks. Back in the early 90's it used to drive me nuts when I cd'd across a symlink and couldn't get back using 'cd ..'. PWD was the solution that the shells adopted for this and Perforce is simply following the convention.

Most of the time that's what's wanted. When it isn't, deleting PWD from the environment usually solves the problem.

Hope that helps!

Tony

On Thursday 06 March 2008 14:29:24 bob p4 wrote:

[ 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!

!DSPAM:47d0000351257730779061!