The PATH environment variable is always reset to a system-dependent default path
It seems that /usr/local/bin/ is only in PATH when running interactive shell. You could tweak the PATH environment variable in your OS, but I think it's better to just change the alias to something like:
When you execute the command via sudo you still have your own environment, therefore your own path. Postfix's local program resets the PATH to a minimum (probably /bin and /usr/bin) when invoking an external program. You can use export_environment config parameter to set a different path. More information
So I assume the postfix user has ruby in its path.
No, it means that the user you issued the sudo with has ruby in its path. A simple sudo doesn't change the $PATH.
The simplest solution for your issue probably would be to just prepend the actual ruby to your script call, something like the following (assuming your ruby lives in /usr/bin/ruby).
发布评论
评论(3)
Postfix 手册 local(8) 介绍了管道别名:
似乎 /usr/local/bin/ 仅在运行交互式 shell 时位于 PATH 中。您可以调整操作系统中的 PATH 环境变量,但我认为最好将别名更改为以下内容:
Postfix manual local(8) says about pipe aliases:
It seems that /usr/local/bin/ is only in PATH when running interactive shell. You could tweak the PATH environment variable in your OS, but I think it's better to just change the alias to something like:
当您通过 sudo 执行命令时,您仍然拥有自己的环境,因此拥有自己的路径。当调用外部程序时,Postfix 的
local
程序将 PATH 重置为最小值(可能是 /bin 和 /usr/bin)。您可以使用export_environment
配置参数来设置不同的路径。 更多信息When you execute the command via
sudo
you still have your own environment, therefore your own path. Postfix'slocal
program resets the PATH to a minimum (probably /bin and /usr/bin) when invoking an external program. You can useexport_environment
config parameter to set a different path. More information不,这意味着您发出 sudo 的用户的路径中有 ruby。简单的 sudo 不会更改 $PATH。
对于您的问题,最简单的解决方案可能是将实际的 ruby 添加到您的脚本调用中,如下所示(假设您的 ruby 位于
/usr/bin/ruby
中)。No, it means that the user you issued the sudo with has ruby in its path. A simple sudo doesn't change the $PATH.
The simplest solution for your issue probably would be to just prepend the actual ruby to your script call, something like the following (assuming your ruby lives in
/usr/bin/ruby
).