gpt4 book ai didi

ruby - 如何从 rake 任务启动 IRB 控制台?

转载 作者:数据小太阳 更新时间:2023-10-29 06:47:34 24 4
gpt4 key购买 nike

我正在尝试编写一个 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 foorake 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 正在查看 ARGV,其中包含来自 rake 命令行的任务名称。先尝试清除 ARGV。

require 'irb'
ARGV.clear
IRB.start

关于ruby - 如何从 rake 任务启动 IRB 控制台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2683854/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com