Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8148895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:44:08+00:00 2026-06-06T14:44:08+00:00

I’m trying to create a Rake task that invokes two other rake tasks. I’ve

  • 0

I’m trying to create a Rake task that invokes two other rake tasks. I’ve found people with related questions here and here, but it hasn’t been very useful. This is what I’ve cobbled together so far. Any idea what I’m doing wrong?

task :cron => :environment do
  #if Time.now.hour % 2  == 0 
    Rake::Task["robots:update_robots"].reenable
    Rake::Task["robots:update_robots"].invoke
  #end
end

As you can see, it’s a cron job that’s meant for Heroku to do. But I’ve commented out what I don’t need so I can test that it’s working.

I keep getting this error:

Don’t know how to build task ‘robots:update_robots’

But I have no idea why.

UPDATE: So I it turns out I wasn’t able to run the original task that was being called by my cron rake task. I had it running ok for a while, buy somewhere along the line, I deleted the “d” in “update”. So this command
Rake::Task[“robots:upate_robots”].execute
didn’t because the robots rake task was “upate”, not “update”.

Tl;dr: typos.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:44:10+00:00Added an answer on June 6, 2026 at 2:44 pm

    In general, your solution should work:

    require 'rake'
    
    task :environment do
      puts 'task environment'
    end
    
    namespace :robots do
      task :update_robots do
        puts "task robots:update_robots"
      end
    end
    
    task cron: :environment do
      puts 'task cron'
      Rake::Task['robots:update_robots'].reenable
      Rake::Task['robots:update_robots'].invoke
    end
    
    Rake::Task['robots:update_robots'].invoke
    Rake::Task[:cron].invoke
    
    # >> robots:update_robots was invoked
    # >> task robots:update_robots
    # >> task environment
    # >> task cron
    # >> task robots:update_robots
    

    My first thought is that you must have the rake task wrong (are you sure it’s “robots:update_robots” ?)

    It’s unusual to me that you need to reenable it, this implies that what you want is not Rake, but just plain old Ruby. Move the contents of the update_robots task out to a method which you can then invoke directly instead of trying to treat tasks like methods (tasks are for handling dependencies, they only invoke once on purpose, and your need to bend them around that implies you’re using the wrong tool for the job). Then, both your code and the robots:update_robots can just call the same method:

    require 'rake'
    
    def update_robots
      puts "method update_robots"
    end
    
    task :environment do
      puts 'task environment'
    end
    
    namespace :robots do
      task :update_robots do
        update_robots
        puts "task robots:update_robots"
      end
    end
    
    task cron: :environment do
      puts 'task cron'
      update_robots
    end
    
    Rake::Task['robots:update_robots'].invoke
    Rake::Task[:cron].invoke
    
    # >> method update_robots
    # >> task robots:update_robots
    # >> task environment
    # >> task cron
    # >> method update_robots
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.