ruby rake utility on the command line
Pregunta
So I am very new to Ruby, but I have written a few rake files to get the hang of things, and they worked perfectly well. Fast forward through a vacation, and now I can't get them to run at all, even the most basic rake file that only contains a 'put'
I am only running the rake utility on the command line, in the same directory as my rake file, yet I am dogged by a 'No Rakefile found' error.
My Internet research repeatedly says to make sure you're in your application directory, but as far as I can tell, I have not made an app.
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>'
Thanks.
Solución
your rakefile needs to be named one of these: rakefile, Rakefile, rakefile.rb, Rakefile.rb
or you need to pass rake the -f
flag and specify a file like this:
rake -f my_awesome_rakefile.rb
so heres a tutorial:
create a file named my_awesome_rakefile.rb and fill it with:
task :check_awesomeness do
puts "still awesome!"
end
now run rake -f my_awesome_rakefile.rb check_awesomeness
from the same directory as my_awesome_rakefile.rb and check if it's still awesome.
or you could rename the file to rakefile
and rename the task to default
and just run rake
by itself.
p.s. man rake
is your friend. and this too: http://rake.rubyforge.org/files/doc/rakefile_rdoc.html .