I use rake and its Rakefile to automate the build and documentation generation. A handy tool, but there is one problem.

If the called command (via sh ) returns the status not zero, then this is considered as an error, and an exception is thrown, and the execution of the task stops. This behavior suits me, but because of the throwing of an exception, a long ruby-backtrace is shown, which does not interest me at all, only hides compiler errors from me.

I was looking for how to disable this backtrace, found such a solution:

 sh "some command" do |t, ok| puts "error" if not ok end 

Works, execution stops, backtrace is not displayed. But if it is used as a dependency in another task , then it does not work: the execution of a task with an error stops, and it is considered to be executed correctly, which is incorrect behavior.

How to make rake not output backtrace?

    1 answer 1

    Rakefile:

     desc "lol" task :lol do sh "touch /1" end 

    Run:

     $ rake lol touch /1 touch: cannot touch ?/1?: Permission denied rake aborted! Command failed with status (1): [touch /1...] Tasks: TOP => lol (See full trace by running task with --trace) 

    No traces. Something is wrong with you, see the dotfiles.