Tagged Questions
287
votes
7answers
65k views
How do I pass command line arguments to a rake task?
I've got a rake task that I am making that needs to insert a value into multiple databases.
I'd like to be able to pass this value into the rake task from the command line, or from another rake ...
154
votes
6answers
39k views
How to run Rake tasks from within Rake tasks?
I have a Rakefile that compiles the project in two ways, according to the global variable $build_type, which can be :debug or :release (the results go in separate directories):
task :build => ...
123
votes
7answers
24k views
Why does Ruby 1.9.2 remove “.” from LOAD_PATH, and what's the alternative?
The latest changesets to Ruby 1.9.2 no longer make the current directory . part of your LOAD_PATH. I have a non-trivial number of Rakefiles that assume that . is part of the LOAD_PATH, so this broke ...
74
votes
5answers
31k views
Rails Rake: How to pass in arguments to a task with :environment
So I am able to pass in arguments as follows
desc "Testing args"
task: :hello, :user, :message do |t, args|
args.with_defaults(:message => "Thanks for logging on")
puts "Hello #{args[:user]}. ...
60
votes
5answers
21k views
already activated rake error (when not using bundle exec)
This is kinda weird - i do not think i changed any code in this particular application (but i was working on another app and performing some gem updates there)
When i started running the rake cron on ...
47
votes
4answers
7k views
How do I return early from a rake task?
I have a rake task where I do some checks at the beginning, if one of the checks fails I would like to return early from the rake task, I don't want to execute any of the remaining code.
I thought ...
46
votes
7answers
15k views
Better ruby markdown interpreter?
I'm trying to find a markdown interpreter class/module that I can use in a rakefile.
So far I've found maruku, but I'm a bit wary of beta releases.
Has anyone had any issues with maruku? Or, do you ...
42
votes
10answers
18k views
How do I run a rake task from Capistrano?
I already have a deploy.rb that can deploy my app on my production server.
My app contains a custom rake task (a .rake file in the lib/tasks directory).
I'd like to create a cap task that will ...
40
votes
8answers
20k views
Rails task: script/runner or rake?
For ad hoc Rails tasks we have a few implementation alternatives, chief among which would seem to be
script/runner some_useful_thing
and
rake some:other_useful_thing
Which option should I ...
39
votes
4answers
7k views
Default task for namespace in Rake
Given something like:
namespace :my_tasks do
task :foo do
do_something
end
task :bar do
do_something_else
end
task :all => [:foo, :bar]
end
How do I make :all be the default ...
37
votes
3answers
2k views
How do I use “gets” on a rake task?
I get an error whenever I try to use the function gets within a rake task. Is there a way to make it work?
The error says, "no such file or directory - (rake task name)"
34
votes
6answers
12k views
Why is rake db:migrate:reset not listed in rake -T?
Why are some rake tasks not listed by rake -T? Like db:migrate:reset? I can execute it without a problem, but why is it not listed there? Is there a way to get a real full list of rake tasks?
% rake ...
34
votes
3answers
8k views
Rake “already initialized constant WFKV_” warning
Trying to run rake cucumber:ok and am getting this error:
/Users/dev/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already ...
33
votes
4answers
20k views
uninitialized constant Rake::DSL in Ruby Gem
I have been working on updating my gem (whm_xml at https://github.com/ivanoats/whm_xml_api_ruby ) to make it work with ruby 1.9.2, latest rubygems, latest bundler, latest rdoc, latest rake. It works ...
31
votes
3answers
5k views
Rake vs Thor for automation scripts?
I want to automate things like:
Creating a new Rails app with pre-selected database, git initialize it, create heroku project, commit all files, etc.
Upload all files in folder to another computer ...