为什么rake aborts [rake --tasks]无法在我的Windows机器上加载这样的文件?

时间:2012-08-28 16:34:09

标签: ruby windows rake

我正在尝试从没有rails或任何东西的目录执行rake任务。只是一个目录和里面的Rakefile.rb。

目前我不知道为什么会失败。但我认为从Rakefile所在的目录中执行rake应该从这个rakefile执行任务。我错过了加载路径吗?

我的环境

Win7 (x64)

ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

rake, version 0.9.2.2

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby193/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby193/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby193/lib/ruby/gems/1.9.1
     - C:/Users/pantarhei/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

这是错误消息

[rake --tasks] rake aborted!
cannot load such file -- D:/Projects/_Web/FOO/Rakefile
C:/Ruby193/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
C:/Ruby193/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
C:/Ruby193/bin/rake:32:in `<main>'


    [rake --prereqs] rake aborted!
cannot load such file -- D:/Projects/_Web/FOO/Rakefile
C:/Ruby193/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
C:/Ruby193/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
C:/Ruby193/bin/rake:32:in `<main>'

2 个答案:

答案 0 :(得分:1)

您可以尝试将Rakefile.rb重命名为Rakefile(不带.rb扩展名),然后再试一次吗?

还可以尝试:

rake -T -fRakefile.rb

作品。

答案 1 :(得分:0)

在您撰写Reakefile.rb的问题中;我不知道这是否只是问题中的拼写错误,或者目录中的rakefile是否实际上是这样调用的,但要确保它被称为RakefileRakefile.rb