0

On OS X Snow Leopard, I'm running the default Apache with perlbrew.

My PATH points to the perlbrew perl, so I expected /usr/bin/env perl to do the same, which it does from bash, but not via cgi scripts, which seem to use the system perl.

How can I have Apache use the perlbrew perl?

Update

This question is answered on StackOverflow: $PATH environment variable for apache2 on mac

Interesting that PHP people consider it a valid question, but Perl people do not. It would have been helpful for the Perl people to have taken a few seconds to mention why they think the question does not relate to programming and matters as described by the FAQ.

Community
  • 1
  • 1
Lee Goddard
  • 10,680
  • 4
  • 46
  • 63

1 Answers1

3

When you run /usr/bin/env perl, it finds perl somewhere in your $PATH environment variable...which is set in one of your dotfiles (probably .bash_profile or .bashrc).

When Apache starts up, it typically gets started by launchd and does not receive any environment setup services from your shell initialization scripts. You would need to modify the script that starts Apache to add the necessary directories to $PATH, or modify your CGI scripts to call the appropriate perl binary directly (by using #!/path/to/my/perl instead of #!/usr/bin/env perl).

larsks
  • 277,717
  • 41
  • 399
  • 399
  • This happens when apache is launched as `/usr/sbin/httpd -k start` from my dev shell. I can't use an explicit path, as the live machine and other devs setups are currently unknown quantities. – Lee Goddard Jan 18 '13 at 13:49
  • 1
    You could use SetEnv directives in your Apache configuration to set `$PATH`. – larsks Jan 18 '13 at 14:56
  • Could do, but I still want to know why this is happening. – Lee Goddard Jan 19 '13 at 17:01