]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/CGI_wrapper_doesn__39__t_store_PERL5LIB_environment_variable.mdwn
Fix dangling link to branch I deleted after merge. Link instead to merged commits...
[ikiwiki.git] / doc / bugs / CGI_wrapper_doesn__39__t_store_PERL5LIB_environment_variable.mdwn
1 If you wish to install ikiwiki in your home directory (for example because you don't have root access), you need to set environment variables (such as PATH and PERL5LIB) to point to these directories that contain your personal copy of IkiWiki.
2
3 The CGI wrapper remembers PATH, but not the environment variable PERL5LIB. Consequently, it will look for plugins and so on in the usual system directories, not in your personal copy. This is particularly insidious if you have a system copy of a different version installed, as your CGI wrapper may then load in code from this version.
4
5 I think the CGI wrapper should remember PERL5LIB too.
6
7 -- Martin
8
9 Thank's a lot for pointing me to this location in the code. I was looking it for some time.
10
11 This brutal patch implement your solution as a temporary fix.
12
13     *** Wrapper.pm.old      2012-08-25 16:41:41.000000000 +0200
14     --- Wrapper.pm  2012-10-01 17:33:17.582956524 +0200
15     ***************
16     *** 149,154 ****
17     --- 149,155 ----
18       $envsave
19             newenviron[i++]="HOME=$ENV{HOME}";
20             newenviron[i++]="PATH=$ENV{PATH}";
21     +       newenviron[i++]="PERL5LIB=$ENV{PERL5LIB}";
22             newenviron[i++]="WRAPPED_OPTIONS=$configstring";
23       
24       #ifdef __TINYC__
25
26 As I am not sure that remembering `PERL5LIB` is a good idea, I think that a prettier solution will be to add a config variable (let's say `cgi_wrapper_perllib`) which, if fixed, contains the `PERL5LIB` value to include in the wrapper, or another (let's say `cgi_wrapper_remember_libdir`), which, if fixed, remember the current `PERL5LIB`.
27
28 -- Bruno
29
30 **Update:** I had not seen this bug earlier, but I ran into the same issue and made a more general solution. You can already add stuff to `%config{ENV}` in the setup file, but it was being processed too late for `PERL5LIB` to do any good.
31 [This change](http://source.ikiwiki.branchable.com/?p=source.git;a=log;h=29e80b4eedadc2afd3f9f36d215076c82982971b;hp=6057107d71e9944bd6fd7093060e4297e617733e) moves the `%config{ENV}` handling earlier in the wrapper, so anything specified there is placed back in the actual environment before Perl gets control. Problem solved!
32
33 -- Chap
34
35 > Thanks, this looks like a nicer solution than the above. Some review:
36 >
37 >     + $val =~ s/([\\"])/\\$1/g;
38 >
39 > This is *probably* OK, because the configuration is unlikely to include
40 > non-ASCII, but I'd prefer something that covers all possibilities,
41 > like this:
42 >
43 >     my $tmp = $val;
44 >     utf8::encode($tmp) if utf8::is_utf8($tmp);
45 >     $tmp =~ s/([^A-Za-z0-9])/sprintf "\\x%02x", $1/ge;
46 >
47 > and then passing $tmp to addenv.
48 >
49 >     + delete $config{ENV};
50 >
51 > I don't think this is particularly necessary: there doesn't seem any harm
52 > in having it in the storable too?
53 >
54 > --[[smcv]]
55
56 Happy to make the escaping change, thanks for the sharp eye.
57
58 > [[Merged|done]] with that change. --[[smcv]]
59
60 My thinking on `delete` is once it's handled, it's handled. The C code
61 is going to put this straight into the real environment and then do
62 a simple `exec` ... is there any way this hasn't been handled?
63
64 It just takes up space twice in the generated wrapper otherwise.
65 Admittedly it's not much space, but seems to be even less point ... ?
66
67 -- Chap
68
69 > That makes sense, as long as nothing else is going to read
70 > `$config{ENV}` for purposes other than copying it into the actual
71 > environment. --[[smcv]]