This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id:
29002
Status:
open
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
adamk [...] cpan.org
Cc:
AdminCc:

BugTracker
Severity:
Wishlist
Broken in:
0.2808
Fixed in:
(no value)



Subject: Module::Build::Base::cwd breaks symlinks
When Module::Build gets the current working directory, it uses Cwd::cwd. Cwd::cwd removes symlinks. This unlinked path is both used for Module::Build itself, and is also the context that the tests will be run in. If the code in the module has any functionality that relies on the path that it is running in, this results in a change of behaviour that can break the code/tests. Module::Build::Base::cwd needs to be changed to a version that doesn't break symlinks, using $ENV{PWD} (if it is set). sub cwd { require Cwd; if ( defined $ENV{PWD} ) { return $ENV{PWD}; } else { return Cwd::cwd(); } } or alternatively... (but a bit more evil) sub cwd { require Cwd; require File::Spec; Cwd::chdir(File::Spec->curdir); return $ENV{PWD}; }
Using $ENV{PWD} would likely create more bugs than it would eliminate, because typically that variable isn't kept in sync with chdir() unless the coder takes some special measures. I agree that the alternative is a bit more evil, probably too evil. For these reasons it has become a best practice not to rely on a certain string representation of the CWD to be exactly what you left it as. For instance, under Windows the CWD might change from "C:\Program Files" to "C:\Progra~1" or whatever, even without symlinks or chdir(). To deal with this unpleasantness in M::B we write a "magic number" to a file in _build/ , then check later that this number is the same as what we wrote. That lets the name of the directory change, and even lets the directory be moved around, without breaking. Could an approach like that be taken with your app? -Ken


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.