我正在尝试编写一个rake任务,它将设置镜像我的项目的环境。如何从rake任务启动IRB控制台?
task :environment do
require 'rubygems'
require 'sequel'
# require 'my_projects_special_files'
end
task :foo => [:environment] do
require 'irb'
IRB.start
end
引出IRB抱怨说,“富”不存在(任务名称)
10:28:01:irb_test >> rake foo --trace (in /Users/mwlang/projects/personal/rake/irb_test) ** Invoke foo (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute foo rake aborted! No such file or directory - foo /opt/local/lib/ruby/1.8/irb/input-method.rb:68:in `initialize' /opt/local/lib/ruby/1.8/irb/input-method.rb:68:in `open' /opt/local/lib/ruby/1.8/irb/input-method.rb:68:in `initialize' /opt/local/lib/ruby/1.8/irb/context.rb:80:in `new' /opt/local/lib/ruby/1.8/irb/context.rb:80:in `initialize' /opt/local/lib/ruby/1.8/irb.rb:92:in `new' /opt/local/lib/ruby/1.8/irb.rb:92:in `initialize' /opt/local/lib/ruby/1.8/irb.rb:57:in `new' /opt/local/lib/ruby/1.8/irb.rb:57:in `start' /Users/mwlang/projects/personal/rake/irb_test/Rakefile:9
确实是这个问题!感谢您的回答 – 2011-08-01 14:42:47
也谢谢! @MichaelLang你应该已经接受了这个答案。 – 2012-03-12 11:18:55
在Ruby 2.4.0中有更直接的方法来做到这一点;看到我的答案。 – 2017-01-12 03:11:19