ruby / ruby/rake

rake -P output is ambiguous with prereq namespaces

Open
#704 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.5k
Forks
650
Avg merge
6m
Merged PRs (30d)
3

Description

When tasks are in a namespace, their pre-reqs "inherit" the namespace prefix.

Given the following rakefile:

task :setup do
  puts "global setup, oops"
end

namespace :tool do
  task :setup do
    puts "setting up"
  end
  task run: :setup do
    puts "running"
  end
  task run2: 'tool:setup' do
    puts "running a second way"
  end
end

The both tasks run and run2 have the same pre-req (setup). However, task run omits the namespace, while run2 is explicit with its pre-req's namespace. Both forms work as expected:

$ rake tool:run
setting up
running

$ rake tool:run2
setting up
running a second way

However, when the pre-req tree is printed, rake is not clear about what the pre-reqs' full names are.

$ rake -P
rake setup
rake tool:run
    setup  # <--- This is ambiguous!
rake tool:run2
    tool:setup
rake tool:setup

The expectation is that rake -P prints the "fully resolved" pre-reqs and is thus clear about what task will actually be run. In the example above, it is not clear what tool:run's pre-req is. Is it the "global" setup, task as it appears in the -P output? Or is it in fact tool:setup because it is namespaced?

To be clear, rake's invocation behavior matches my expectations: tool:run invokes tool:setup, not setup. But this behavior is not evident in rake's --prereqs output.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the rake -P/--prereqs output entry point and reproduce the Rakefile shown in the issue. Trace how namespaced prerequisites are resolved for tool:run and tool:run2, then verify that the printed prerequisite for both is fully qualified and unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.