You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a small Dockerfile that uses perl:5 as the source image. Its attached below.
A RUN task in the Dockerfile calls carton install - which finishes without an error. cpanfile also attached.
The actual perl script is started using Dockers CMD.
The perl script dies because it can't find DateTime in @INC - but carton pretended to install it.
Here's the actual output when after carton exec ./bin/fetcher.pl:
Can't locate DateTime.pm in @INC (you may need to install the DateTime module) (@INC contains: ./lib ../lib /usr/src/fetcher/local/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at ./bin/fetcher.pl line 12.
BEGIN failed--compilation aborted at ./bin/fetcher.pl line 12.
As you can see, Carton added /usr/src/fetcher/local/lib/perl5 to the list of include paths. That seems correct - the modules seem to be installed here:
root@5871e7e089ab:/usr/src/fetcher# ls /usr/src/fetcher/local/lib/perl5
B DateTime Dist Eval File HTTP LWP Log Module Net Params Role Specio.pm TODO.pod Try URI.pm lwpcook.pod namespace Class Devel Encode Exception HTML IO LWP.pm MRO Mozilla Package REST Specio Sub Test URI WWW lwptut.pod x86_64-linux
But there's no DateTime.pm .. The file seems to be installed in the x86_64-linux subdirectory:
root@5871e7e089ab:/usr/src/fetcher# ls /usr/src/fetcher/local/lib/perl5/x86_64-linux/
DateTime DateTime.pm HTML List Net Package Scalar Sub Variable auto perllocal.pod
I have no idea, why this happens or why this path isn't added to @INC ?!?
Dockerfile
FROM perl:5
RUN cpanm Carton
WORKDIR /usr/src/fetcher
COPY cpanfile* /usr/src/fetcher/
COPY bin /usr/src/fetcher/bin
COPY lib /usr/src/fetcher/lib
RUN carton install
# Run the app
CMD carton exec ./bin/fetcher.pl
I could not reproduce your issue https://github.com/skaji/carton-issue219
The arch directory /usr/src/fetcher/local/lib/perl5/x86_64-linux must be in @INC by PERL5LIB.
Use #!/usr/bin/env perl on your scripts, this will find the correct perl.
Regarding your docker and carton setup, an alternative (shameless plug): I keep a perl5-based image that takes care of all of details to install a perl application that uses Carton. It also includes hooks to install extra packages with apt-get (perl5 image is based on Ubuntu) before carton install.
For example, your image copies cpanfile* first but then copies bin and lib before carton install. This will skip a great feature of docker build, layer caching. You should copy cpanfile*, run carton install, and then copy everything else you need.
If you do it this way, the carton install step, which usually takes quite some time, will be cached between docker build's as long as your cpanfile* are untouched. You can tweak bin and lib, rebuild, and carton install layer will be reused. A major speed up on docker build's.
Problem
perl:5
as the source image. Its attached below.carton install
- which finishes without an error. cpanfile also attached.@INC
- but carton pretended to install it.Here's the actual output when after
carton exec ./bin/fetcher.pl
:As you can see, Carton added
/usr/src/fetcher/local/lib/perl5
to the list of include paths. That seems correct - the modules seem to be installed here:But there's no
DateTime.pm
.. The file seems to be installed in thex86_64-linux
subdirectory:I have no idea, why this happens or why this path isn't added to
@INC
?!?Dockerfile
cpanfile
The text was updated successfully, but these errors were encountered: