Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Rule dependencies' behaviour is strange, possibly broken or poorly documented

未关闭
#626 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby
领域
build-system

调研方向

根据提供的 Rakefile 重现报告:先运行 rakerake test.prerake test0.txtrake test.txt,然后修改 test.pretest0.pre 后再次运行。跟踪 Rake 的规则依赖解析和时间戳处理。完成标准是依赖行为得到修正或有明确文档说明,并且两个案例都有回归覆盖。

由索引模型根据 Issue 内容生成。

描述

Consider this Rakefile:

require 'rake/clean'

task default: :test
task test: 'test.txt'

file 'test.txt' => 'test0.txt'

rule '.txt' => '.pre' do |t|
  sh 'cp', t.source, t.name
end

rule '.pre' do |t|
  sh 'touch', t.name
end

CLEAN.include('*.pre')
CLOBBER.include('*.txt')

This Rakefile demonstrates 2 related issues.

The implicit dependency test.pre is not built automatically

In a folder containing only this Rakefile, try:

$ rake
touch test0.pre
cp test0.pre test0.txt
cp test.pre test.txt
cp: cannot stat 'test.pre': No such file or directory
rake aborted!
Command failed with status (1): [cp test.pre test.txt...]
[...]

This creates test0.pre and test0.txt, but fails to create test.pre and test.txt.

However, the following sequence of commands works without issues:

$ rake test.pre
touch test.pre
$ rake
touch test0.pre
cp test0.pre test0.txt
cp test.pre test.txt

Thus, rake knows how to build test.pre, but skips it unless asked explicitly.

Note that despite skipping test.pre, rake builds test0.pre automatically, while both are dependencies by the same rule.

In fact, starting from a folder containing only this Rakefile,

  • rake test0.txt works,
  • rake test.txt fails.

Updating test.pre does not trigger rebuilding of test.txt

Assume that everything has been built with

$ rake test.pre
$ rake

Now, try this:

$ touch test.pre
$ rake

Nothing happens.

Now, try:

$ touch test0.pre
$ rake
cp test0.pre test0.txt
cp test.pre test.txt

This triggers rebuilding.

Rake version

rake version: 13.0.6.

主要语言
Ruby
星标
2.5k
派生
650
平均合并
6 分钟
30 天内合并 PR
3

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/rake 的其他 Issue

查看 ruby/rake 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。