grobber has asked for the wisdom of the Perl Monks concerning the following question:

I'm running:
${HOME}/perl5/bin/cpan version 1.64 calling Getopt::Std::getopts (vers +ion 1.12 [paranoid]), running under Perl version 5.28.1.
I have been trying to run installs without testing by setting the CPAN_OPTS environment variable as documented in the cpan manpages. The problem is that the contents of that variable seem to be appended rather than prepended to the rest of my arguments. The three commands
cpan CPAN -T CPAN_OPTS="-T" cpan CPAN export CPAN_OPTS="-T" && cpan CPAN
have exactly the same effect:
Loading internal logger. Log::Log4perl recommended for better logging Reading '${HOME}/.cpan/Metadata' Database was generated on Thu, 02 Jan 2020 14:41:03 GMT CPAN is up to date (2.27). >(error): Could not expand [-T]. Check the module name. >(info): I can suggest names if you install one of Text::Levenshtein:: +XS, Text::Levenshtein::Damerau::XS, Text::Levenshtein, and Text::Leve +nshtein::Damerau::PP >(info): and you provide the -x option on invocation. >(error): Skipping -T because I couldn't find a matching namespace.

---
I have posted an issue on github at https://github.com/andk/cpanpm/issues/131 but I thought perhaps someone here might have some insight that could help resolve this faster.

Replies are listed 'Best First'.
Re: how is the CPAN_OPTS environment variable supposed to work?
by 1nickt (Canon) on Jan 03, 2020 at 03:14 UTC

    Hi grobber,

    I am afraid all I can do is confirm the behaviour you report above.

    To workaround it I set a shell alias with alias cpan="cpan -T"

    (...although I personally use cpanm...)

    Hope this helps!


    The way forward always starts with a minimal test.

      cpanm lets you set this up with the environment variable PERL_CPANM_OPT=-n, confirmed working.

        Thanks!

        The discussion on github has since extended to track down the actual issue in the cpan source code: it pushes the contents of CPAN_OPTS onto the argument array instead of unshifting. We'll see if the devs end up making that small change to fix this.