[Catalyst] Catalyst 5.90010 server must be in CWD to run?

Eden Cardim edencardim at gmail.com
Tue Feb 21 13:24:06 GMT 2012


>>>>> "Louis" == Louis Erickson <lerickson at rdwarf.net> writes:

    Louis> Looking at @INC, it's clear that Catalyst no longer adds
    Louis> "$basename/../inc" to the path - I haven't dug into the code to
    Louis> find where the change was.

You mean ../lib, right?

    Louis> I know all the help and samples have people run
    Louis> "script/myapp_server.pl", but I never do; I run it from the script
    Louis> directory.

There's no problem with that at all (caveats given below), but do you have a
specific reason for doing it that way?
    
    Louis> I'm also concerned that having to be in the right CWD
    Louis> will allow loading of unexpected modules, rather than being based
    Louis> on the app's location, as I'd expect.

This isn't much about the CWD, it's about setting the right @INC, which is a
problem related to perl (and pretty much any programming language) as a
whole. You can run the app from anywhere, as long as you tell it where to find
the libs it needs. If you used the standard scaffolding script, that should be
lib/ under your MyApp dir, plus the site_perl libs (which are hard-coded into
@INC by the perl binary in most cases). If you're concerned about loading
unexpected modules, sanitize @INC before you use() anything. Catalyst tries to
make a few guesses as to what @INC should be, and the doc examples try to
match those assumptions, but there's no way it can catch all the possible
scenarios, so if for some reason you decide to do something different than
what's doc'ed, you'll need to adjust the environment accordingly.

    Louis> Is this a deliberate change?  Is there a reason for it?  Or is it
    Louis> an unexpected change?

    Louis> So, I'd think this is deliberate.  It will also affect all the
    Louis> scripts.  What is this going to do to myapp_fastcgi, when the
    Louis> webserver doesn't set the WD as expected?

I'm not exactly sure about the specific motivation for that change, but
script/myapp_fastcgi.pl is just a perl source like any other, adjust @INC
before running it (via PERL5LIB, -I, etc.) and you'll be fine.

-- 
      Eden Cardim         Need help with your Catalyst or DBIx::Class project?
      Code Monkey                 http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.    Want a managed development or deployment platform?
 http://edencardim.com            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list