Read more

Hide a Rake task from the `rake -T` list

Henning Koch
November 17, 2016Software engineer at makandra GmbH

A Rake task appears in rake -T if it has a description:

desc 'Compile assets'
task :compile do
  ...
end
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

To not list it, simply omit the description:

task :compile do
  ...
end

You can also hide a Rake task that has been defined by someone else (like a gem) by removing the description:

Rake::Task['compile'].clear_comments

Or you can whitelist which tasks should be listed:

visible_tasks = %w(compile build package)
Rake::Task.tasks.each do |task|
  visible_tasks.include?(task.name) or task.clear_comments
end
Posted by Henning Koch to makandra dev (2016-11-17 12:37)