skaji/cpm

Should Carton::Snapshot be included in the fatpack?

Opened this issue · 3 comments

It seems strange that I'd get an error from cpm telling me to install a module so that it can read the list of modules I want it to install:

die "To load $self->{snapshot}, you need to install Carton::Snapshot.\n";

To me it would make some sense to bundle Carton::Snapshot into the fatpacked version of cpm.

For reference i've got a cpm in vendor/ in my repo, so my Dockerfile is just

COPY vendor/cpm /bin/cpm
COPY cpanfile* /app/
RUN cd /app && cpm install

personally I'd expect cpm to either completely ignore the cpanfile.snapshot or automatically support it.

I agree with the sentiment here. The only reason I can come up with is that Carton requires 5.8.5 and App::cpm targets 5.8.1, but surely this is a bump we can make? 5.8.5 was released in 2004.

If that's not an option, perhaps we can have an easier way to build that ourselves? I'm thinking something like this:

index 6153f05..4a2a58c 100644
--- a/author/fatpack.pl
+++ b/author/fatpack.pl
@@ -20,14 +20,17 @@ Show new dependencies
 
 =cut
 
+my %cli_options;
+
 Getopt::Long::GetOptions
     "f|force" => \my $force,
     "t|test" => \my $test,
     "u|update-only" => \my $update_only,
+    "with-recommends" => \( $cli_options{with_recommends} ),
 or exit 1;
 
 sub cpm {
-    App::cpm::CLI->new->run(@_) == 0 or die
+    App::cpm::CLI->new(%cli_options)->run(@_) == 0 or die
 }
 
 sub fatpack {
@@ -97,7 +100,7 @@ my $exclude = join ",", qw(
     URI
 );
 
-my $target = '5.8.1';
+my $target = $cli_options{with_recommends} ? '5.8.5' : '5.8.1';
 
 my ($git_describe, $git_url);
 if (my $version = $ENV{CPAN_RELEASE_VERSION}) {

which would mean we can run author/fatpack.pl --with-recommends --force to generate a version that includes Carton::Snapshot (and whatever else gets recommended in the future). @skaji, would you accept something like that as a PR?

This would be really handy for us too. Or at least the option of downloading a fatpack cpm without Carton::Snapshot and one with it included (if file size is a factor). As it stands today for example, the official perl Docker images which include the fatpack can't install dependencies when a snapshot is present out of the box.

Huge love and thanks
Fotis