Marking tasks as :phony fails to prevent rebuild

Open
#25 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #203 by @juank-pa — closed without merging

Assessment

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

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.

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

Dominant language
Ruby
Stars
2.5k
Forks
649
Avg merge
4m
Merged PRs (30d)
5

Getting set up

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.

More from ruby/rake

All issues in ruby/rake

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.