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

Cannot manage libs with Apache2 #764

Open
arseniigorkin opened this issue Nov 10, 2022 · 0 comments
Open

Cannot manage libs with Apache2 #764

arseniigorkin opened this issue Nov 10, 2022 · 0 comments

Comments

@arseniigorkin
Copy link

I have installed perlbrew and installed two Perls with it. Now I am trying to separate libraries for modules I install with cpanm.

I want (if possible) to switch to one Perl (within Perlbrew) (for example: 5.22.4) and once I call cpanm install Some::Module the module will be installed in the separate library, related only to this Perl.

Then, in the script, I would like to have like the example below:

#!/usr/bin/env perl

use strict;
use Some::Module;
print "Content-type:text/html\n\n";
print "Works!";

and that's it. No any other use lib 'path'; or so. I tried to use perlbrew lib create perl-5.22.4@somename and then switch to it.

Then call cpanm install Some::Module and I see the result at the location ~/.perlbrew/perl-5.22.4@somename/lib/perl5/Some/Module.pm, but when I call my script from a browser I see Error 500 and the logs say "missing module Some::Module, check @inc etc..."

What I also found that if I move the ~/.perlbrew/perl-5.22.4@somename/lib/perl5/Some/Module.pm to ~/perl5/perlbrew/perls/perl-5.22.4/lib/5.22.4/Some/Module.pm or to /home/arseniigorkin/perl5/perlbrew/perls/perl-5.22.4/lib/site_perl/5.22.4/x86_64-linux/Some/Module.pm then the script works. And Perl 5.22.4 (in our example) has its own library without need to use use lib 'path';

But, how to set up Perlbrew to switch cpanm automatically to this directory?

What I was also trying: cpanm install -l /home/arseniigorkin/perl5/perlbrew/perls/perl-5.22.4/lib/site_perl/5.22.4/x86_64-linux Some::Module to specify the target lib dir, but it creates the next tree under /home/arseniigorkin/perl5/perlbrew/perls/perl-5.22.4/lib/site_perl/5.22.4/x86_64-linux instead:

lib
    perl5
        Some
            Module.pm
        x86_64-linux
            auto
                [.....]
            .meta
                [.....]
            perllocal.pod
        install.pm
man
    man3
        [.....]

and, sadly, the script throws Error 500.

So, is there a possibility to omit use lib 'path'; in the script, switching between multiple Perl versions in Perlbrew?

This all happens on Ubuntu 22.04.
When switching to perl-5.22.4@somename and installing Some::Module via cpanm the module appears under the ~/.perlbrew/perl-5.22.4@somename/lib/perl5/Some/Module.pm as mentioned above, but the CGI script fails with Error 500.

However, when I execute the next command: perlbrew list-modules it shows Some::Module as installed under the current Perl (which I am switched to). So, this is a dissonance: Perlbrew "sees" the module under the specific Perl, but the CGI script cannot "see" this module under the same Perl.

The output of the use Data::Dumper; print Dumper(\@INC); is $VAR1 = [ '/home/arseniigorkin/perl5/perlbrew/perls/perl-5.22.4/lib/site_perl/5.22.4/x86_64-linux', '/home/arseniigorkin/perl5/perlbrew/perls/perl-5.22.4/lib/site_perl/5.22.4', '/home/arseniigorkin/perl5/perlbrew/perls/perl-5.22.4/lib/5.22.4/x86_64-linux', '/home/arseniigorkin/perl5/perlbrew/perls/perl-5.22.4/lib/5.22.4', '.' ];

What is interesting is that calling the same script from the terminal gives no errors on this module, but the browser says "Error 500" and logs say there is no module in the @inc...

Please, help me to set up the Apache2 server with perlbrew with automatic switching Perl and its lib, without the need to alter my scripts. Thank you!

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

1 participant