Reputation: 2240
I can't install a Perl module. I have it installed and working OK on another laptop. Can I copy the whole installation from that laptop? What I tried:
Path
variable. Now perl --verion
successfully presents itself as ActiveState.
However, it still looks for modules under c:\Strawbwerry not under c:\Perl64\lib, where Image::Magick is really present (copied from the old laptop). Is there an environment variable to control where pel will look for modules?
Is there anything else that I should copy from my old laptop?
I would prefer simple solutions, without compiling things locally.
And without changing my Perl code itself
Both systems (new - target and old - source) are Windows-10
Very strangely perl-V says:
@INC:
C:/Perl64/site/lib
C:/Perl64/lib
And still it does not find Image::Magick, which really is present in:
C:\Perl64\site\lib\Image\Magick.pm
Strangely, the error message says:
Can't locate Image/Magick.pm in @INC (you may need to install the Image::Magick module) (@INC entries checked: C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib)
Note that these @INC entries do not correspnd to to the value of @INC reported by perl -V
(see above)
Interestingly, on the old (source) laptop, perl-V
reports the same as o the new (target) one:
@INC:
C:/Perl64/site/lib
C:/Perl64/lib
And there Image::Magick works OK, with the same tree od c:\Perl64 .Upvotes: 1
Views: 143
Reputation: 2584
If your goal is just to run this Perl application on different systems, it's trivial to write a Dockerfile for the application, then spin a container from it to have it work regardless of the system, as long as they have Docker:
FROM perl:5.40
RUN cpan -I App::cpanminus
# You may need to install other libraries onto the container for Image::Magick
# but once you have it working once it should work forever.
RUN cpanm Image::Magick
COPY myscript.pl .
CMD ["perl", "myscript.pl"]
Now you can generate a container:
docker build -t mycontainer .
docker run -it mycontainer
Now you shouldn't have to worry about copying installations over, or any other hacks.
Upvotes: 1
Reputation: 132905
Personally, I'd spend the extra time to install the Perl you want and the ImageImagick stuff you want. There's value in learning and smoothing the deployment. Consider what you are going to do next time this has to happen, such as when your computer dies, is stolen, or whatever. Maybe we can help figure out the ActiveState problem.
I think you need to unset the environment variables that Strawberry Perl was using to join to its library. In particular, you want to pay attention to PERL5LIB
and PERLLIB
. You don't want to share those across the perls compiled by different toolchains.
The error message, however, looks like you are running Strawberry Perl since @INC
doesn't have the ActiveState directories. You'll have to figure that out—probably by removing the perl you don't want to use.
The output of perl -V
should show you settings of any environment variables that start with PERL
.
Additionally, Perl modules compiled against external libraries may need parts of those and those parts may exist outside of the Perl directories. Not only that, those external libraries need to be a version compatible with the one the module was compiled against.
Upvotes: 2