I recently startet to use a small wrapper script to setup the environment (including cpan module installation with cpanfile and cpanm) to allow our jenkins server to perform clean testing of the git master.
Everything needed apart from already installed system perl is stuffed in ./local and used with eval `perl -Mlocal::lib=local` to setup the env and exec the actuall app (in our case prove for testing or hypnotoad for production serving). Works out very well, as also devs can now simply setup a new environment in one shot. Does not fit in every development or deployment process, but for us it seems to work out for now. BR +rl On Sat, Oct 18, 2014 at 9:12 AM, Jan Henning Thorsen <[email protected] > wrote: > perl -I is not inherited through exec(). You're better off using: > > PERL5LIB=$PWD/perl5/lib/perl5 $PWD/perl5/bin/hypnotoad > > This way, PERL5LIB is set for the current process and all the sub > processes started with exec(). Note the $PWD part, which will make sure > it's set to an absolute path. > > On Saturday, October 18, 2014 6:01:15 AM UTC+2, perlpong wrote: >> >> This is not a bug-report or a request for help, I am just sharing my >> experience. >> >> I install Mojolicious inside an app-local directory using cpanm's "-L" >> switch: >> >> . >> |─- perl5/ >> | |-- bin/ >> | | |-- hypnotoad >> | | |-- mojo >> | | |-- morbo >> | |-- lib/ >> | |-- perl5/ >> | |-- Mojo/ >> | |-- Mojo.pm >> | |-- Mojolicious/ >> | |-- Mojolicious.pm >> |-- script/ >> |-- app.pl >> >> I run hypnotoad with Perl's "-I" flag to append my local-lib directory to >> the beginning of @INC: >> >> perl -Iperl5/lib/perl5 perl5/bin/hypnotoad ./script/myapp.pl >> >> My app logs an error related to Mojolicious: >> >> Can't locate object method "every_param" via package >> "Mojo::Parameters" >> >> After investigating I realise that my "global" install of Mojolicious is >> being loaded instead of my local one. >> >> If I dump @INC at the beginning of the hypnotoad script, it produces this: >> >> ( >> "/home/ac/apps/MyApp/perl5/bin/../lib", >> "perl5/lib/perl5/i686-linux", >> "perl5/lib/perl5", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_ >> perl/5.16.1/i686-linux", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1/i686-linux", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1", >> ".", >> ) >> ( >> "/home/ac/apps/MyApp/perl5/bin/../lib", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_ >> perl/5.16.1/i686-linux", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1/i686-linux", >> "/home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1", >> ".", >> ) >> >> It appears that the process restarts itself, the second time without my >> modified @INC. >> >> Looking inside Mojo::Server::Hypnotoad, I notice this: >> >> $ENV{HYPNOTOAD_EXE} ||= $0; >> ... >> # Clean start (to make sure everything works) >> die "Can't exec: $!" if !$ENV{HYPNOTOAD_REV}++ && !exec >> $ENV{HYPNOTOAD_EXE}; >> >> So my workaround is to manually set the HYPNOTOAD_EXE environment >> variable: >> >> export HYPNOTOAD_EXE="perl -Iperl5/lib/perl5 perl5/bin/hypnotoad" >> perl -Iperl5/lib/perl5 perl5/bin/hypnotoad ./script/myapp.pl >> > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
