Item13227: Bootstrap fails under Mod_Perl
Priority: Urgent
Current State: Closed
Released In: 2.0.0
Target Release: major
FindBin ends up finding apache instead of the bin script.
AUTOCONFIG: Found Bin dir: /usr/sbin, Script name: apache2 using FindBin
AUTOCONFIG: barfilicious: Set DefaultUrlHost http://localhost
AUTOCONFIG: REQUEST_URI is (undef)
AUTOCONFIG: SCRIPT_URI is (undef)
AUTOCONFIG: PATH_INFO is
AUTOCONFIG: ENGINE is Foswiki::Engine::Apache2::MP20
Use of uninitialized value in index at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Load.pm line 710.
AUTOCONFIG: URI Prefix is
Use of uninitialized value in pattern match (m//) at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Load.pm line 718.
AUTOCONFIG: Building Short URL paths using prefix
AUTOCONFIG: Using ScriptUrlPath /bin
AUTOCONFIG: Using {ScriptUrlPaths}{view}
AUTOCONFIG: Using PubUrlPath: /pub
AUTOCONFIG: ToolsDir = /usr/tools
AUTOCONFIG: ScriptDir = /usr/bin
AUTOCONFIG: WorkingDir = /usr/working
AUTOCONFIG: LocalesDir = /usr/locale
AUTOCONFIG: TemplateDir = /usr/templates
AUTOCONFIG: PubDir = /usr/pub
AUTOCONFIG: DataDir = /usr/data
AUTOCONFIG: Unable to use PlainFileStore: ,v files were found in data or pub, which indicates this installation is already configured for RCS e.g. Search failed: Directory open of /usr/data failed. Check permissions.
--
GeorgeClark - 24 Jan 2015
Not really sure what the best way to fix this is. I've got it working, but looking for better ideas.
Change tools/mod_perl_startup.pl
to set a ENV variable for the scripts directory.
diff --git a/tools/mod_perl_startup.pl b/tools/mod_perl_startup.pl
index 06c5b24..19d9e8b 100755
--- a/tools/mod_perl_startup.pl
+++ b/tools/mod_perl_startup.pl
@@ -32,6 +32,8 @@ BEGIN {
last;
}
pop @path while $path[-1] eq '';
+ $path[-1] = 'bin';
+ $ENV{FOSWIKI_SCRIPTS} = File::Spec->catdir(@path);
$path[-1] = 'lib';
unshift @INC, File::Spec->catpath( $vol, File::Spec->catdir(@path) );
push @path, qw(CPAN lib);
Change bootstrap to use the $ENV{FOSWIKI_SCRIPTS}
if defined
diff --git a/core/lib/Foswiki/Configure/Load.pm b/core/lib/Foswiki/Configure/Load.pm
index 3dcf05c..9af424f 100644
--- a/core/lib/Foswiki/Configure/Load.pm
+++ b/core/lib/Foswiki/Configure/Load.pm
@@ -380,15 +380,22 @@ sub bootstrapConfig {
# rewriting is happening in the web server this is likely
# to go down in flames, but it gives us the best chance of
# recovering. We need to guess values for all the vars that
- # woudl trigger "undefined" errors
- eval "require FindBin";
- die "Could not load FindBin to support configuration recovery: $@"
- if $@;
- FindBin::again(); # in case we are under mod_perl or similar
- $FindBin::Bin =~ /^(.*)$/;
- my $bin = $1;
- $FindBin::Script =~ /^(.*)$/;
- my $script = $1;
+ # would trigger "undefined" errors
+ my $bin;
+ my $script = '';
+ if ( defined $ENV{FOSWIKI_SCRIPTS} ) {
+ $bin = $ENV{FOSWIKI_SCRIPTS};
+ }
+ else {
+ eval "require FindBin";
+ die "Could not load FindBin to support configuration recovery: $@"
+ if $@;
+ FindBin::again(); # in case we are under mod_perl or similar
+ $FindBin::Bin =~ /^(.*)$/;
+ $bin = $1;
+ $FindBin::Script =~ /^(.*)$/;
+ $script = $1;
+ }
print STDERR
"AUTOCONFIG: Found Bin dir: $bin, Script name: $script using FindBin\n"
if (TRAUTO);
--
GeorgeClark - 24 Jan 2015
Still some issues. Because the BEGIN block runs before any path information is available, the bootstrap gets the
DefaultUrlHost
and other settings wrong. We probably need to run bootstrap a 2nd time in the Foswiki::new(), so that the paths can be properly applied.
This is probably the same with
FastCGI.
--
GeorgeClark - 24 Jan 2015
These are hopefully fixed. Need validation.
--
GeorgeClark - 23 Feb 2015