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

  • Home
  • SEARCH
  • 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 9195255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:35:23+00:00 2026-06-17T21:35:23+00:00

I am basically trying to convert a solution to this question into a rake

  • 0

I am basically trying to convert a solution to this question into a rake task: How do I find the source file for a rake task?

I want to type, e.g.:

rake meta:where[test]

And get the path where the test task is defined. Here’s what I have, with some unnecessary stuff so I can make some relevant comments:

Rake::TaskManager.record_task_metadata=true

namespace :meta do
  desc "meta:where[taskname] - where is taskname defined?"
  task :where, [:taskname] do |t, args|
    tsk = Rake.application.tasks.each.find {|t| t.name == args.taskname}
    puts tsk
    tsk.locations.each {|x| puts x}
  end
end

So, puts tsk actually outputs ‘test’, which means (I think!) I’m correctly locating the task here. It’s no trouble printing the path from the rails console using the same code (as in the above-mentioned SO post). It says something like:

/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.11/lib/rails/test_unit/testing.rake:49:in `<top (required)>'

Any idea how I can get the location(s) to print?

  • 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-17T21:35:24+00:00Added an answer on June 17, 2026 at 9:35 pm

    As stated above, code from the linked question works, e.g.

    namespace :meta do
      desc "meta:where[taskname] - where is taskname defined?"
      task :where, [:taskname] do |t, args|
        puts "looking for #{args.taskname}"
        tsk = Rake.application[args.taskname]
        # It is mysterious to me why this would need to be so complicated
        puts tsk.actions.map(&:source_location)
      end
    end
    

    But if anyone can explain why the code in the question above doesn’t work, or why the source_locations access has to be so complicated, I’d still love to know!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert a uncommon date format into a standard date. Basically
I'm trying to convert this ASP.net(vb) script to pure Javascript and I'm running into
I am basically trying to convert a string similar to this one: 2011-11-9 18:24:12.3
I'm having trouble trying to convert a text file into a list of lists
I'm basically trying to convert a Unix timestamp (the time() function) to a relative
Basically on .show() I've been trying to have all of the inputs convert to
I'm basically trying to extract a Mac application from a zip file using QuaZip.
I'm basically trying to do a dropdown jquery plugin. HTML <script type='text/javascript' src='script.js'></script> <div
Trying to convert super(B, self).method() into a simple nice bubble() call. Did it ,
I'm trying to convert something from my excel spreadsheets into Javascript and came along

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.