ruby / ruby/rake

Marking tasks as :phony fails to prevent rebuild

Open
#25 3 comments 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

The :phony task fails to prevent rebuild of FileTasks dependent on non-file tasks.

lib/rake/phony.rb
# Defines a :phony task that you can use as a dependency. This allows
# file-based tasks to use non-file-based tasks as prerequisites
# without forcing them to rebuild.
#
# See FileTask#out_of_date? and Task#timestamp for more info.

require 'rake'

task :phony

Rake::Task[:phony].tap do |task|
  def task.timestamp # :nodoc:
    Time.at 0
  end
end
Code reproducing bug
require 'rake/phony'

task :default => 'final.file'

file 'final.file' => ['source.file', :intermediate] do |f|
  touch f.name
end

# Marked as phony, so should not force FileTask to rebuild
task :intermediate => [:phony] do |t|
  puts "#{t.name} task"
end
Bug demo
$ touch source.file      # Create the source file
$ rake                   # Run Rake to build 'final.file'
intermediate task
touch final.file
$ rake                   # Rake should NOT rebuild, but does.     <<<<<<<<
intermediate task
touch final.file

Mentioned here

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 with lib/rake/phony.rb, then read FileTask#out_of_date? and Task#timestamp as the issue suggests. Run the provided reproduction with source.file and final.file, comparing the first and second rake runs. Done means a :phony prerequisite no longer causes the dependent FileTask to rebuild on the second run.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.