问题描述
所以我决定拆分我的上一篇文章,因为该错误与 ByeBug 相关而不是与 Pry-Remote 相关(我认为).最后发表网址:
还创建了一个 ByeBug 问题:https://github.com/deivid-rodriguez/pry-byebug/issues/78
我正在运行的内容:
gem 'pry-byebug', '=1.3.3'宝石'撬堆栈_资源管理器'宝石撬轨"宝石'撬遥控'撬 (0.10.2)coderay (~> 1.1.0)method_source (~> 0.8.1)slop (~> 3.4)pry-byebug (1.3.3)再见(~> 2.7)撬 (~> 0.10)撬轨 (0.3.4)撬 (>= 0.9.10)撬遥控 (0.1.8)撬 (~> 0.9)slop (~> 3.0)pry-stack_explorer (0.4.9.2)binding_of_caller (>= 0.7)撬 (>= 0.9.11)红宝石 2.2.3p173(2015-08-18 修订版 51636)[x86_64-darwin14]导轨 4.2.4
注意 1:
更新了所有与撬相关的宝石
https://gist.github.com/YOUConsulting/65cdcdc22d32780dde51
您似乎在使用旧版本的 pry-byebug
,在撰写本文时最新版本是 3.2.0
但您使用的是 1.3.3
.如果您更新您的宝石,那么问题很有可能会消失.
更新
经过进一步研究,看起来 pry-remote 和 pry-byebug 在 Ruby 2.x 上不能很好地协同工作.
然而,编码员发布了一些代码,大多数评论都是日语,但他们声称它可以使 pry-remote 工作.我在下面包含了他们的代码(我也翻译了日语):
module ObjectUtils# remote 参数是ip地址,默认端口是9876def pry!(远程=零,端口=9876)$LOAD_PATH.unshift "#{ENV['RUBY_PATH']}/调试器"需要撬"如果 __callee__ == :pry1 和 !Pry.instance_variable_get(:@pry_is_start) 则返回Pry.instance_variable_set(:@pry_is_start, true)# 如果定义?撬和定义?PryStackExplorer 和 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# 结尾如果远程或 ENV['USE_PRY_REMOTE']如果定义?PryNav如果定义?ActionDispatch # rails 应用程序.如果 Pry.initial_session?警告 '[0m[33mloading pry remote ...[0m']binding.of_caller(1).remote_pry(remote, port)结尾别的binding.of_caller(1).remote_pry(remote, port)结尾别的require_remote_debuggerbinding.of_caller(1).remote_pry(remote, port)`notify-send -t 5000 -- "exiting pry remote ..."` if find_executable 'notify-send'结尾别的# 如果定义了这些常量,那么您已经在调试器会话中如果定义?PryByebug 或定义?PryDebugger 或定义?PryNav如果定义?ActionDispatch # rails 应用程序.如果 Pry.initial_session?# 当发送一个新的请求时,它会重置 Pry.initial_session?是真的.# 这确保了在同一个请求中调试器将被激活一次.# 只有在下一个请求时才会重新初始化警告 '[1m[33mloading 调试器 ...[0m'binding.of_caller(1).pry结尾别的binding.of_caller(1).pry结尾别的require_debuggerbinding.of_caller(1).pry结尾结尾结尾def require_debuggercase RbConfig::CONFIG['ruby_version']当'2.0.0'...'3.0.0'需要'pry-byebug'当'1.9.0'...'2.0.0'需要撬调试器"结尾# 确保调试器已加载警告 '[1m[33mloading 调试器 ...[0m'需要'ap';AwesomePrint.pry!救援加载错误需要撬导航"警告 '[1m[33mloading 调试器 ...[0m'结尾def require_remote_debugger需要远程撬"需要撬导航"警告 '[0m[33mloading pry remote ...[0m']`notify-send -t 10000 -- "loading pry remote ..."` if system 'which notify-send &>/dev/null'需要'ap';AwesomePrint.pry!结尾结尾Kernel.send(:include, ObjectUtils)Object.send(:include, 内核)
您需要调用这些方法,并且可能需要根据您的使用情况调整它们.
参考资料
- https://github.com/Mon-Ouie/pry-remote/问题/58
- https://github.com/Mon-Ouie/pry-remote/issues/35#issuecomment-20290739
- https://github.com/deivid-rodriguez/pry-byebug/问题/33
- https://rubygems.org/gems/pry-byebug
So I've decided to split my last post since the bug is Related to ByeBug more than to Pry-Remote (I think). Last post URL: Pry-Remote not triggered Rails 4
Problem:
When typing Next in Pry-Remote, ByeBug acts unexpectedly and goes to "teardown".
Also created an ByeBug Issue: https://github.com/deivid-rodriguez/pry-byebug/issues/78
What I am running:
gem 'pry-byebug', '=1.3.3'
gem 'pry-stack_explorer'
gem 'pry-rails'
gem 'pry-remote'
pry (0.10.2)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (1.3.3)
byebug (~> 2.7)
pry (~> 0.10)
pry-rails (0.3.4)
pry (>= 0.9.10)
pry-remote (0.1.8)
pry (~> 0.9)
slop (~> 3.0)
pry-stack_explorer (0.4.9.2)
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
Rails 4.2.4
Note 1:
Updated all the pry related gems
https://gist.github.com/YOUConsulting/65cdcdc22d32780dde51
You seem to be using an ancient version of pry-byebug
, the latest as of this writing is 3.2.0
but you're using 1.3.3
. If you update your gems there's a good chance the problem will go away.
UPDATE
After further research it looks like pry-remote and pry-byebug do not work well together on Ruby 2.x.
However, there is a bit of code a coder posted, most of the comments are in Japanese, but they claim it makes pry-remote work. I'm including their code below (I've translated the Japanese as well):
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)
You'll need to call these methods, and might need to tweak them for your usage.
References
- https://github.com/Mon-Ouie/pry-remote/issues/58
- https://github.com/Mon-Ouie/pry-remote/issues/35#issuecomment-20290739
- https://github.com/deivid-rodriguez/pry-byebug/issues/33
- https://rubygems.org/gems/pry-byebug
这篇关于Pry Remote/ByeBug 接下来进入拆解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!