我希望能够在 Windows 7 上创建一个 rakefile,我可以使用 rake -g <taskname>
调用该文件。或rake --system <taskname>
命令。我在哪里保存 rakefile?我尝试在我的用户目录(c:\users\me\rake)下创建一个 Rake 目录,但是当我调用 rake -g hello_world
时,排除错误,说它不知道如何构建 :hello_world
任务,这让我认为它只是看不到 rakefile。这是我的全局 rakefile 的样子:
require 'rake'
desc "a hello world task"
task :hello_world do
puts "hello from your global rakefile"
end
最佳答案
弄清楚了 - 结果 Rake 期望全局 rakefiles 以“.rake”扩展名结尾。我将上面的示例更改为:
require 'rake'
desc "a hello world task"
task :hello_world do
puts "hello from {__FILE__}"
end
并将其保存为“testing.rake”在我的 c:\users\me\rake\目录中。我打开一个随机目录的命令提示符并运行“rake -g hello_world”并得到以下输出:
C:\Windows\system32>rake -g hello_world
(in C:/Windows/system32)
hello from C:/Users/me/Rake/testing.rake
关于ruby - 如何在 Windows 7 上创建全局 rakefile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5278629/