Alexander Gelbukh
Alexander Gelbukh

Reputation: 2240

Perl: Is it possible to copy a complete Perl installation to another computer?

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:

Upvotes: 1

Views: 143

Answers (2)

Rawley Fowler
Rawley Fowler

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

brian d foy
brian d foy

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

Related Questions