如何从rake任务启动IRB控制台?
我正在尝试编写一个rake任务,它将设置一个镜像我的项目的环境。
task :environment do
require 'rubygems'
require 'sequel'
# require 'my_projects_special_files'
end
task :foo => [:environment] do
require 'irb'
IRB.start
end
导致irb抱怨“foo”不存在(任务的名称)
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
IRB.start正在查看包含来自rake命令行的任务名称的ARGV。 尝试先清除ARGV。
require 'irb'
ARGV.clear
IRB.start
从Ruby 2.4.0开始,你可以这样做:
require 'irb'
binding.irb
显然,你如何定义你的任务一定有问题。 如果你改变会发生什么
task :foo => [:environment] do
至
task :foo => :environment do
链接地址: http://www.djcxy.com/p/62873.html
上一篇: How do I start IRB console from a rake task?
下一篇: C# stop webbrowser control from loading images, flash, script, etc