Rake task executing twice when only called once

Viewed 2579

I've written a very simple rake task to try and locate the source of this problem.

namespace :foo do
 task bar: :environment do
  puts 'RUNNING'
 end
end

When executed in the console rake foo:bar the output is:

RUNNING
RUNNING

This occurs when I execute any rake task. Has anyone encountered anything like this before?

EDIT

The above rake task is all that is written in that .rake file.

Here is the Rakefile currently being used.

require File.expand_path('../config/application', __FILE__)

OurApp::Application.load_tasks

Also here is the output from running a --trace.

** Invoke foo:bar (first_time)
** Invoke environment (first_time)
** Execute environment
Hostname is: ourhost
** Execute foo:bar
RUNNING
RUNNING
3 Answers

For me my rake environnement was loading twice in my rails app because of the presence in my test file of :

setup do
  MyApp::Application.load_tasks
end

I removed it and the task was invoked once.

Hope it can help.

Sorry for my english.

Related