in reply to Configuring CPAN out of script does not work

I assume that /etc/perl is part of your @INC. If it's not, then you may have problem there. I don't understand why you configure cpan manually like that. If you run cpan as root for the first time, the CPAN/Config.pm file will be created automatically (for example in /usr/lib/perl5/5.8.8, but it depends on your local @INC setting) and you have a chance to configure it. Oh, now I think about it, you might want to write your own CPAN::Config to keep your default the same across systems so you don't have to run into manual and boring prompted-configuration process.

CPAN.pm seems to always complain whenever it finds that one or more config item is missing and then offers a reconfiguration. The problem is, you write the config items manually from the script (if I get you correctly). You say you set them all. But installed CPAN.pm may have newer config item(s) you haven't handled yet. I touch my CPAN/MyConfig.pm very rarely. Yet when I upgrade CPAN.pm (with significant change on the config items), it will tell me about missing/uninitialized configuration item(s). For me, it's not a problem. I take it as part of the upgrading process.

So I don't think that the complain is due to some magical cheking in CPAN.pm (I haven't looked at the source code thoroughly but I won't bother for this case). One suggestion if you want to keep your method is: run the cpan for the first time as root to create the initial CPAN/Config.pm. It should be guaranteed that it will contain the complete items the current CPAN.pm has. Open the newly created file, take all its items, and override the ones with your own values, and save it back. It shouldn't be hard to modify your script. Good luck!


Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Replies are listed 'Best First'.
Re^2: Configuring CPAN out of script does not work
by isync (Hermit) on Aug 22, 2007 at 20:14 UTC
    "run the cpan for the first time as root to create the initial CPAN/Config.pm"

    Actually, that's exactly what I did (cos I am lazy..)

    I went to /etc/perl/CPAN/Config.pm, opened it in an editor and copy/pasted it over into the
    print FILE " --here goes the config, would paste it but not at hand (and is actuall +y nothing special)--- ";
    So when I run my script it overwrites the contents of the Config.pm properly. Then I run cpan and it complains. I redo the config questions and then cpan runs ok.

    When I re-run my script to test, and replace the file once again with the same data, cpan again complains...

    Any further ideas? (I will see if my script really writes the config file cpan is contacting under the user I am trying this.. Although it should be the one: cpan states this path right after startup..)