Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t/Plack-Util/load.t test #11 fails in environments that load FindBin early. #448

Closed
hartzell opened this issue Feb 25, 2014 · 3 comments
Closed

Comments

@hartzell
Copy link

Test #11 in t/Plack/Util/load.t fails in one of my environments.

That environment uses a sitecustomize.pl file that happens to load FindBin. Beyond loading FindBin, in this particular situation the sitecustomize.pl file is a no-op.

The problem seems to be that _load_sandbox, which is called by load_psgi tries to fake out "FindBin etc." by locally setting $0.

If FindBin's init sub has already been called (e.g. by a call to use elsewhere) then this fakery is insufficient. (See the known issues section of the FindBin man page).

The test can be made to pass in my environment changing t/Plack-Util/bin/findbin.psgi to include a call to FindBin::again() after the use FindBin statement.

This behavior of load_psgi, resetting $0 and @ARGV, does not seem to be documented in the Plack::Util::load_psgi documentation. If it is supported behavior then perhaps it should be described in the documentation and a warning included about this failure mode.

@miyagawa
Copy link
Member

@hartzell
Copy link
Author

If you're going to recommend a practice (for instance here: https://github.com/plack/psgi-specs/wiki/PSGI-file-evaluation-convention), then I think that the safer idiom is to call FindBin::again():

# app.psgi
use FindBin;
FindBin::again();
use lib "$FindBin::Bin/lib";
use MyApp; 
MyApp->psgi_app;

This follows the advice given in the KNOWN-ISSUES section of the FindBin docs.

In particular, it would be great if the Plack test case followed this practice so that automated tools (e.g. Carton, Pinto) can be installed without intervention.

@hartzell
Copy link
Author

Spring cleaning, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants