I have a custom Apache initializer开发者_如何转开发s in order to have my Homebrew binaries accessible:
SetEnv PATH /usr/local/bin:/usr/local/sbin:$PATH
However, my Rails (3.0.4) applications cannot find any binaries unless full paths are given. For example:
begin
`convert`
raise Errno::ENOENT if $?.exitstatus == 127
rescue Errno::ENOENT
logger.info "command 'convert' not found: ensure Image Magick is installed"
end
Results in an exception being raised each time (even though the convert binary exists under '/usr/local/bin/convert'). Any ideas on how to fix this so my Rails applications know about the path? Thanks!
I'm not sure if I did a system update or what happened exactly, but I had both Brew and Port configured on my system. I had two initializer files:
# ./other/port.conf
SetEnv PATH /opt/local/bin:/opt/local/sbin:$PATH
# ./other/brew.conf
SetEnv PATH /usr/local/bin:/usr/local/sbin:$PATH
The soution was to remove the unused port.conf
. Not sure why this was causing issues in Apache (and I seem to remember it working in the past). However, multiple calls to SetEnv
seem to overwrite eachother.
This may not be your specific problem, but it's something to check.
There was a regression in Apache that made SetEnv
not work for PATH
. This was fixed in revision 965679 (July, 2010). If you're using an older installation of Apache, you may be hitting this bug.
In config/environments/production.rb
, you can set environment variables like this:
ENV["PATH"] = "..."
精彩评论