There are plenty of reasons why a Rake task could be running twice, and in this specific case I think it could have to do with the Rake environment loading more than once, as the question linked by @kucaahbe suggests.
I actually got here looking for help myself but my issue was different and I managed to find the answer. Don't think it will help this particular issue but I'll leave it here too.
Make sure your Rake environment is loading only once
Following the question linked by @kucaahbe, it suggests this would happen if your environment is loading and initializing Rake twice.
In the context a Rake task runs rake has already been required and initialized, so make sure your task does not include the following lines:
require 'rake'
...
Rake.application.init
Rake.application.load_rakefile
In this specific case the task does not seem to be doing anything of the sort, so I would check other tasks or the Rakefile for something forcing the Rake context to be loaded twice.
Clear pre-existing tasks before redefining them
Just had this issue due to a gem creating a Rake task with the same name.
For instance, if you declare the following task in a Rails application:
namespace :assets do
task :precompile do
puts "Hello"
end
end
and run rake assets:precompile:
...
I, [2017-07-31T11:25:09.498897 #9455] INFO -- : Writing /home/pfac/...css.gz
Hello
Hello
But if you use Rake::Task#clear:
namespace :assets do
task(:precompile).clear
task :precompile do
puts "Hello"
end
end
it disables any pre-existing behaviour and prints only Hello.
I don't think this option solves this particular issue, unless @broc-broccoli has been defining other foo:bar rake tasks.
Anyway, hope this helps.
rails_12factorcauses double log entries. If you have it installed make sure you're only loading it in the :production environment:gem 'rails_12factor', group: :production- infusedrakeor a rake file again possibly? googling "rake executing twice" has a lot of possible reasons why this would happen but most of them seem to boil down to multiple require or initialization where they are not needed. - engineersmnkyrake foo:bar --tracewhich displays the order of tasks. That might give you an idea of whats calling the particular task twice. - Dharam Gollapudiputs "STILL RUNNING"and show us the output so that we can rule out a possible double echoing to the console? - Matouš Borák