0

所以我对 Ruby 很陌生,但我已经编写了一些 rake 文件来掌握事情的窍门,它们运行得非常好。通过假期快进,现在我根本无法让它们运行,即使是最基本的仅包含“put”的 rake 文件

我只在命令行上运行 rake 实用程序,与我的 rake 文件位于同一目录中,但我被“未找到 Rakefile”错误所困扰。

我的互联网研究反复说要确保你在你的应用程序目录中,但据我所知,我还没有制作过应用程序。

C:\Users\me\.rake>rake mytask --trace
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:495:in `raw_
load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block
 in load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `stan
dard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_
rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block
 in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `stan
dard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
C:/Ruby192/bin/rake:19:in `load'
C:/Ruby192/bin/rake:19:in `<main>'

谢谢。

4

1 回答 1

2

您的 rakefile 需要命名为以下之一:rakefile、Rakefile、rakefile.rb、Rakefile.rb 或者您需要传递 rake-f标志并指定如下文件:

rake -f my_awesome_rakefile.rb

所以这里有一个教程:

创建一个名为my_awesome_rakefile.rb的文件并填写:

task :check_awesomeness do
  puts "still awesome!"
end

现在rake -f my_awesome_rakefile.rb check_awesomeness从与 my_awesome_rakefile.rb 相同的目录运行并检查它是否仍然很棒。

或者您可以将文件rakefile重命名为并将任务重命名为default并自行运行rake


psman rake是你的朋友。这也是:http ://rake.rubyforge.org/files/doc/rakefile_rdoc.html 。

于 2012-01-26T07:45:22.157 回答