miyagawa / cpanminus

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

Running cpanm in Puppet #640

Closed Levelleor closed 2 years ago

Levelleor commented 2 years ago

I am unable to get cpanm working via Puppet. Manually everything's fine, when running via Puppet all sorts of issues come up. First one was solved defining PERL_CPANM_HOME as per https://github.com/miyagawa/cpanminus/issues/37.

Though now I face "Invalid metadata structure" issue on MacOS.

Here're the logs I get:

--> Working on HTML::Parser
Fetching http://www.cpan.org/authors/id/O/OA/OALDERS/HTML-Parser-3.76.tar.gz ... OK
syntax error at /usr/local/bin/cpanm line 68, near ")m{die "Invalid metadata structure. Errors: " .join(", ",$cmv->errors)."\n"}"
BEGIN not safe after errors--compilation aborted at /usr/local/bin/cpanm line 68.
Compilation failed in require at /usr/local/bin/cpanm line 549.

Any suggestions on how to get further? Or maybe anyone has any suggestions of how to properly install cpan modules via Puppet?

miyagawa commented 2 years ago

"Invalid metadata structure" is not the actual error message. That is a quote from a compilation failure of /usr/local/bin/cpanm at line 68, which is bizarre, and doubly weird because cpanm itself seemed to have run correctly to a point where it fetched the tarball.

I'm not really sure what's happening, but given that you have no issues with running it outside Puppet, I'd bet it would be a different PATH, or some other environment variables that are in play.

Levelleor commented 2 years ago

Looks like it was using a different version of Perl that I've fixed by setting a strict PATH. Then defining both $HOME and $PERL_CPANM_HOME fixed the issue. Now just have to get rid of all the extra perl's.

It would be nice if it logged this issue correctly, though, I spent quite some time on finding the solution.