为什么从Ruby调用Bash命令会抛出错误?

Aid*_*anc 3 ruby directory

我正在尝试使用Ruby在某些图像上执行以下bash命令:

class Pingcrush
  def initialize
    Dir.foreach('drawable') do |item|
      next if item == '.' or item == '..'
      # do work on real items
      if item.end_with?(".png") then
        %x["wine pngcrush.exe -brute drawable/#{item} new/#{item}"]
      end
    end
  end
end
Pingcrush.new
Run Code Online (Sandbox Code Playgroud)

我在该目录的父既drawablenew,但是,当我试图运行该脚本,我总是得到同样的错误:

sh: wine pngcrush.exe -brute drawable/feed_cl.png new/feed_cl.png: not found
Run Code Online (Sandbox Code Playgroud)

为什么会这样?我尝试切换我在Ruby中调用的路径,似乎无法使其工作.

Dej*_*jan 5

它执行你的shell但找不到酒.尝试设置安装wine的完整路径.

which wine
Run Code Online (Sandbox Code Playgroud)