所以我决定将我的上一篇文章拆分,因为这个错误与ByeBug相关而不是Pry-Remote(我认为)。最后发布的网址:Pry-Remote not triggered Rails 4
问题:
在Pry-Remote中键入Next时,ByeBug意外动作并转到" teardown"。
还创建了一个ByeBug问题: https://github.com/deivid-rodriguez/pry-byebug/issues/78
我在跑什么:
x = ['A','I','R']
def groupme(x):
s = tuple(x)
for size in range(1, len(s) + 1):
for index in range(len(s) + 1 - size):
yield list(x[index:index + size])
list(groupme(x))
>>> [['A'], ['I'], ['R'], ['A', 'I'], ['I', 'R'], ['A', 'I', 'R']]
注1:
更新了所有与撬相关的宝石
答案 0 :(得分:1)
您似乎使用了pry-byebug
的古老版本,撰写本文时的最新版本为3.2.0
,但您正在使用1.3.3
。如果你更新你的宝石,问题很可能就会消失。
<强>更新强>
经过进一步研究后,看起来pry-remote和pry-byebug在Ruby 2.x上不能很好地协同工作。
然而,编码器发布了一些代码,大部分注释都是日语,但是他们声称这使得它可以进行远程工作。我在下面提供了他们的代码(我也翻译了日语):
module ObjectUtils
# remote parameter is the ip address, default port is 9876
def pry!(remote=nil, port=9876)
$LOAD_PATH.unshift "#{ENV['RUBY_PATH']}/debuger"
require 'pry'
return if __callee__ == :pry1 and !Pry.instance_variable_get(:@pry_is_start)
Pry.instance_variable_set(:@pry_is_start, true)
# if defined? Pry and defined? PryStackExplorer and Pry.config.hooks.hook_exists? :after_session, :delete_frame_manager
# Pry.config.hooks.delete_hook :when_started, :save_caller_bindings
# Pry.config.hooks.delete_hook :after_session, :delete_frame_manager
# end
if remote or ENV['USE_PRY_REMOTE']
if defined? PryNav
if defined? ActionDispatch # rails application.
if Pry.initial_session?
warn '[0m[33mloading pry remote ...[0m'
binding.of_caller(1).remote_pry(remote, port)
end
else
binding.of_caller(1).remote_pry(remote, port)
end
else
require_remote_debugger
binding.of_caller(1).remote_pry(remote, port)
`notify-send -t 5000 -- "exiting pry remote ..."` if find_executable 'notify-send'
end
else
# if these constants are defined then you're already in a debugger session
if defined? PryByebug or defined? PryDebugger or defined? PryNav
if defined? ActionDispatch # rails application.
if Pry.initial_session?
# When sending a new request, it will reset Pry.initial_sesssion? It is true.
# This ensures that, in the same request the debugger will be activated once.
# Only on the next request will it be reinitialized
warn '[1m[33mloading debugger ...[0m'
binding.of_caller(1).pry
end
else
binding.of_caller(1).pry
end
else
require_debugger
binding.of_caller(1).pry
end
end
end
def require_debugger
case RbConfig::CONFIG['ruby_version']
when '2.0.0'...'3.0.0'
require 'pry-byebug'
when '1.9.0'...'2.0.0'
require 'pry-debugger'
end
# to make sure the debugger is loaded
warn '[1m[33mloading debugger ...[0m'
require 'ap'; AwesomePrint.pry!
rescue LoadError
require 'pry-nav'
warn '[1m[33mloading debugger ...[0m'
end
def require_remote_debugger
require 'pry-remote'
require 'pry-nav'
warn '[0m[33mloading pry remote ...[0m'
`notify-send -t 10000 -- "loading pry remote ..."` if system 'which notify-send &>/dev/null'
require 'ap'; AwesomePrint.pry!
end
end
Kernel.send(:include, ObjectUtils)
Object.send(:include, Kernel)
您需要调用这些方法,并可能需要调整它们以供您使用。
参考