miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
746 stars 213 forks source link

How do I run an unpacked version of cpanm? #659

Closed x-yuri closed 1 year ago

x-yuri commented 1 year ago

I tried to find out what --showdeps does, but considering that cpanm is packed, it's not that easy. From what I can tell it can be done like so (I needed it in a docker container):

$ docker run --rm -it alpine:3.17
/ # apk add git perl
/ # git clone https://github.com/miyagawa/cpanminus
/ # cd cpanminus
/cpanminus # perl App-cpanminus/script/cpanm.PL --showdeps Dist::Zilla

This way no packed code is executed. Am I missing something?

miyagawa commented 1 year ago

considering that cpanm is packed, it's not that easy.

Not sure what you mean by this - what is not easy?

This way no packed code is executed.

I don't understand this either. What problem are you trying to solve?

The packed version of cpanm is available in the repository in master branch, so you need to git checkout master before running it, but you seem to want to run unpacked version?

x-yuri commented 1 year ago

Exactly, I'm trying to run the unpacked version, because with the packed version I can neither debug it, nor add debug statements to it.

The problem I'm trying to solve is figure out what --showdeps lists. The way it looks... it lists all the dependencies (direct and indirect). And I need only the direct ones. Moreover it seems like --showdeps needs the dependencies to be installed to list them.

Not sure what you mean by this - what is not easy?

Not easy to figure out what --showdeps does because cpanm is packed. So I first need to clone the repository.

I don't understand this either.

I mean that perl App-cpanminus/script/cpanm.PL seems to run the unpacked version of cpanm.

miyagawa commented 1 year ago

I mean that perl App-cpanminus/script/cpanm.PL seems to run the unpacked version of cpanm.

It does. So you figured out how to do it. What's the problem?

x-yuri commented 1 year ago

So you figured out how to do it.

Now that you said that, there's no problem. You might want to document this, but not sure if many people will need this info. Thanks for the quick reply.

x-yuri commented 1 year ago

So you figured out how to do it. What's the problem?

But if you meant the X problem. I briefly mentioned it. I needed only the direct dependencies. I tried installing Dist::Zilla with cpanm (in a docker/alpine container). It took a while and installed more than hundred packages. So I thought, I can install what I can with apk, and let cpanm install the rest, this way it should be faster. But then I needed the list of the direct dependencies. And the list produced by cpanm --showdeps looked like it included indirect dependences. Surely Dist::Zilla doesn't have that many direct dependencies, I thought. But it appears it does.

--showdeps output mostly matches the list on metacpan. Except that the metacpan list doesn't list configure and test dependencies (only runtime ones). Supposedly. cpanm takes the list from the META.json file. Which is supposedly generated from dist.ini.

Can you possibly confirm that --showdeps lists only the direct dependencies?

miyagawa commented 1 year ago

Yes, the showdeps command shows the direct dependencies, including configure and test dependencies. cpanm does this by downloading the tarball and actually running configure script, then looking up MYMETA.json file.