rubyrakerakefile

Can't call "sh" inside a class on my Rakefile


I'm new to ruby, and I'm writing a pretty basic Rakefile. It contains a class Installer that has a method shell which calls sh like this:

class Installer
  def shell(command)
    sh command
  end
end

When I run it, it throws

NoMethodError: undefined method `sh' for #<Installer:0x00007ffde8098b78>`

I have done some research to see what's wrong but most similar errors appear to be framework/library related, whereas my problem seems to be that it's just not possible to call sh from inside a method.

Is this the problem? if so, what options do I have (considering I want the program to crash if the command failed (which I believe system or backticks won't help here).


Solution

  • Change the sh invocation to Rake.sh. At least, that seemed to work for me.