管道从Postfix到Ruby任务错误的电子邮件

时间:2022-11-19 07:11:01

I'm trying to pipe mail from postfix to a rails tasks. I've got this working successfully when just piping to a vanilla ruby script, but when switching to a rails task I get the following error in the mail.log from Postfix:

我正在尝试将邮件从postfix管道传输到rails任务。只是在使用vanilla ruby​​脚本时,我已经成功地工作了,但是当切换到rails任务时,我在Postfix的mail.log中收到以下错误:

(Command died with status 1: "/usr/local/bin/rake". Command output: /usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in to_specs': Could not find rake (>= 0) amongst [] (Gem::LoadError) from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:into_spec' from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in gem' from /usr/local/bin/rake:22:in' )

(命令死于状态1:“/ usr / local / bin / rake”。命令输出:/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in to_specs':找不到rake(> = /)来自/usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:into_spec'的[](Gem :: LoadError)来自/usr/lib/ruby/1.9.1/rubygems.rb: 1231:在宝石'来自/ usr / local / bin / rake:22:in')

Here is the piping line from master.cf

这是master.cf的管道线

email-task unix - n n - 2 pipe flags=Xhq user=appuser directory=/home/myapp/application/ argv=/usr/local/bin/rake RAILS_ENV=production myapp:process_email

email-task unix - n n - 2个管道标志= Xhq用户= appuser目录= / home / myapp / application / argv = / usr / local / bin / rake RAILS_ENV = production myapp:process_email

Running the command which rake returns /usr/local/bin/rake so I have verified I have the correct rake path.

运行rake返回/ usr / local / bin / rake的命令,这样我就验证了我有正确的rake路径。

I've tried setting ENV['PATH'] inside of the .rake file to /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games and I've also tried cd'ing to the rails app directory in the pipe command but still causes the same error. I've done bundle install and update etc.

我已经尝试将.rake文件中的ENV ['PATH']设置为/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games:/ usr / local / games我也尝试过cd'ing到管道命令中的rails app目录,但仍然会导致同样的错误。我已完成捆绑安装和更新等。

Any help is greatly appreciated...thank you!

非常感谢任何帮助......谢谢!

UPDATE I tried using bundle exec rake etc as suggested but am now getting this error:

更新我尝试使用bundle exec rake等建议,但现在我收到此错误:

Command died with status 127: "/usr/local/bin/bundle". Command output: bundler: command not found: rake Install missing gem executables with bundle install

命令死于状态127:“/ usr / local / bin / bundle”。命令输出:bundler:command not found:rake使用bundle install安装缺少的gem可执行文件

I've tried adding gem 'rake' to the Gemfile as well. I'm assuming bundler can't find the Gemfile?

我也试过在gemfile中添加gem'rake'。我假设bundler找不到Gemfile?

UPDATE (FIXED) So the command that finally worked was the following:

UPDATE(FIXED)所以最终工作的命令如下:

email-task unix - n n - 2 pipe flags=Xhq user=appuser directory=/home/myapp/application/ argv=/usr/local/bin/bundle exec /usr/local/bin/rake RAILS_ENV=production mytask

email-task unix - n n - 2个管道标志= Xhq用户= appuser目录= / home / myapp / application / argv = / usr / local / bin / bundle exec / usr / local / bin / rake RAILS_ENV = production mytask

It was a combination of errors on my part.

这是我的错误组合。

  1. Full paths need to be used for bundle and rake
  2. 需要使用完整路径进行捆绑和耙

  3. app name is not needed in the task param for rake since the directory is being selected before executing
  4. 因为在执行之前选择了目录,所以rake的任务参数中不需要应用程序名称

  5. A side issue: an old version of ruby was being used which caused an unrelated gem error after executing the postfix pipe
  6. 一个侧面问题:正在使用旧版本的ruby,在执行后缀管道后导致无关的gem错误

Appreciate the help everyone.

感谢每个人的帮助。

1 个解决方案

#1


1  

I think your on the wrong track, it's not the system that can't find rake it's your rubygems. Instead of running rake as your command, try running bundle passing whatever you need to in order for it to basically be bundle exec rake...etc

我认为你的错误轨道,不是系统找不到它是你的rubygems。而不是运行rake作为你的命令,尝试运行bundle传递你需要的任何东西,以便它基本上是捆绑exec rake ...等

Update

Based on your new information, it would seem that the rake gem is not installed in your app. Run bundle show rake

根据您的新信息,似乎rake gem未安装在您的应用中。运行bundle show rake

Assuming it's not there, I'm wondering why. Did you ship your app with packaged gems or something? Basically, did you not run bundle install in your deployed app?

假设它不在那里,我想知道为什么。您是否使用打包的宝石或其他东西运送您的应用程序?基本上,你没有在部署的应用程序中运行bundle install吗?

#1


1  

I think your on the wrong track, it's not the system that can't find rake it's your rubygems. Instead of running rake as your command, try running bundle passing whatever you need to in order for it to basically be bundle exec rake...etc

我认为你的错误轨道,不是系统找不到它是你的rubygems。而不是运行rake作为你的命令,尝试运行bundle传递你需要的任何东西,以便它基本上是捆绑exec rake ...等

Update

Based on your new information, it would seem that the rake gem is not installed in your app. Run bundle show rake

根据您的新信息,似乎rake gem未安装在您的应用中。运行bundle show rake

Assuming it's not there, I'm wondering why. Did you ship your app with packaged gems or something? Basically, did you not run bundle install in your deployed app?

假设它不在那里,我想知道为什么。您是否使用打包的宝石或其他东西运送您的应用程序?基本上,你没有在部署的应用程序中运行bundle install吗?