Here's the patch: ============== --- ori/Inline-0.48_01/Inline.pm 2011-04-11 06:10:06.000000000 -0400 +++ Inline-0.48_01/Inline.pm 2011-12-03 16:48:50.000000000 -0500 @@ -728,22 +728,33 @@ } }
- $o->create_config_file($DIRECTORY) - if not -e File::Spec->catfile($DIRECTORY, $configuration_file); - - open CONFIG, "< ".File::Spec->catfile($DIRECTORY, $configuration_file) - or croak M17_config_open_failed($DIRECTORY); - my $config = join '', <CONFIG>; - close CONFIG; - - croak M62_invalid_config_file(File::Spec->catfile($DIRECTORY, $configuration_file)) - unless $config =~ /^version :/; - if(UNTAINT) { - warn "In Inline::check_config_file(): Blindly untainting Inline configuration file information.\n" unless $o->{CONFIG}{NO_UNTAINT_WARN}; - ($config) = $config =~ /(.*)/s; - } - - %config = Inline::denter->new()->undent($config); + my $load_cfg = sub { + $o->create_config_file($DIRECTORY) + if not -e File::Spec->catfile($DIRECTORY, $configuration_file); + + open CONFIG, "< ".File::Spec->catfile($DIRECTORY, $configuration_file) + or croak M17_config_open_failed($DIRECTORY); + my $config = join '', <CONFIG>; + close CONFIG; + + croak M62_invalid_config_file(File::Spec->catfile($DIRECTORY, $configuration_file)) + unless $config =~ /^version :/; + if(UNTAINT) { + warn "In Inline::check_config_file(): Blindly untainting Inline configuration file information.\n" unless $o->{CONFIG}{NO_UNTAINT_WARN}; + ($config) = $config =~ /(.*)/s; + } + + %config = Inline::denter->new()->undent($config); + } ; + + $load_cfg->() ; + if (! defined $config{languages}->{$o->{API}{language_id}}){ + my $unlink = unlink(File::Spec->catfile($DIRECTORY, $configuration_file)); + if(!$unlink) {warn "Failed to remove config file"} + else {warn "config file removed\n" if $o->{CONFIG}{_TESTING}} + $load_cfg->() ; + } + $Inline::languages = $config{languages}; { ============= I ran the Inline test suite an it passed, but I'm not quite sure how to exactly reproduce the problem. Rob/David can you give it a try? Patrick On Sat, Dec 3, 2011 at 7:51 PM, Sisyphus <sisyph...@optusnet.com.au> wrote: > > ----- Original Message ----- From: "Patrick LeBoutillier" > <patrick.leboutill...@gmail.com> > To: "Sisyphus" <sisyph...@optusnet.com.au> > Cc: "David Oswald" <daosw...@gmail.com>; <inline@perl.org> > Sent: Sunday, December 04, 2011 8:34 AM > Subject: Re: Strategy for improving install success of Inline::CPP > > >> Rob, >> >> It looks to me like %config is populated with the actual contents of >> the config file, >> so $config{languages}->{$o->{API}{language_id}} will never exist at that >> point. > > Damn ... so my patch would have the config file unlinked and then re-created > *every* time a script that uses that config file is run. We don't really > want that to happen. > >> Looks like if the config doesn't contain the current language, you >> need to recreate >> it and try again. Then if it still doens't exist, give an error. > > Yes, that's what I was hoping my patch would achieve - by checking in > advance whether the current language was in there or not. > But if it puts the cart before the horse, then it's of somewhat limited use > ;-) > >> I'll try to come up with a patch for you. > > Thanks - that would be good. > David's not the only one who has come up against this problem. I don't know > if your Inline::Java ever fails with cpan testers because of this, but the > Inline::Python maintainer has also been bitten by this. > That was why I stuck in a 'REWRITE_CONFIG_FILE' config option for module > authors to use in their test scripts - to force the re-creation of the > config file. > But like David says, while that (probably) solves the issue with the cpan > testers, the user may subsequently still come up against that > M19_usage_language error when he runs his own scripts. > > One feels that, in this day and age, this issue should be handled a little > better than is currently the case. > > Cheers, > Rob > -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada