ruby Pry gem被击中,但我无法在控制台中输入任何内容

ux6nzvsh  于 2023-08-04  发布在  Ruby
关注(0)|答案(2)|浏览(99)

奇怪的是,我没有收到任何错误消息,我只是不能使用Prybinding.pry被命中,进程停止。但是我不能实际使用Pry,我试着输入,但它要么不起作用,要么是胡言乱语,而不是我打的键。
如何让Pry工作?我正在运行Ubuntu 14.04.3 LTS,安装的gem列表是:

source 'https://rubygems.org'

gem 'rails', '~>4.2.6'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'shopify_app', '~> 7.2'
gem 'shopify_api'
gem 'puma'
gem 'nokogiri'
gem 'httparty'
gem 'redis'
gem 'redis-namespace'
gem 'redis-rails'
gem 'redis-rack-cache'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'pry'

group :development do
  gem 'spring'
end

字符串
然后所有版本号如下:

GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.7.1)
  actionpack (= 4.2.7.1)
  actionview (= 4.2.7.1)
  activejob (= 4.2.7.1)
  mail (~> 2.5, >= 2.5.4)
  rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.7.1)
  actionview (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  rack (~> 1.6)
  rack-test (~> 0.6.2)
  rails-dom-testing (~> 1.0, >= 1.0.5)
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.7.1)
  activesupport (= 4.2.7.1)
  builder (~> 3.1)
  erubis (~> 2.7.0)
  rails-dom-testing (~> 1.0, >= 1.0.5)
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.7.1)
  activesupport (= 4.2.7.1)
  globalid (>= 0.3.0)
activemodel (4.2.7.1)
  activesupport (= 4.2.7.1)
  builder (~> 3.1)
activerecord (4.2.7.1)
  activemodel (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  arel (~> 6.0)
activeresource (4.1.0)
  activemodel (~> 4.0)
  activesupport (~> 4.0)
  rails-observers (~> 0.1.2)
activesupport (4.2.7.1)
  i18n (~> 0.7)
  json (~> 1.7, >= 1.7.7)
  minitest (~> 5.1)
  thread_safe (~> 0.3, >= 0.3.4)
  tzinfo (~> 1.1)
arel (6.0.4)
builder (3.2.3)
coderay (1.1.1)
concurrent-ruby (1.0.4)
erubis (2.7.0)
execjs (2.7.0)
faraday (0.9.2)
  multipart-post (>= 1.2, < 3)
globalid (0.3.7)
  activesupport (>= 4.1.0)
hashie (3.5.1)
httparty (0.14.0)
  multi_xml (>= 0.5.2)
i18n (0.8.0)
jbuilder (2.6.1)
  activesupport (>= 3.0.0, < 5.1)
  multi_json (~> 1.2)
jquery-rails (4.2.2)
  rails-dom-testing (>= 1, < 3)
  railties (>= 4.2.0)
  thor (>= 0.14, < 2.0)
json (1.8.6)
jwt (1.5.1)
loofah (2.0.3)
  nokogiri (>= 1.5.9)
mail (2.6.4)
  mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
  mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.7.0.1)
  mini_portile2 (~> 2.1.0)
oauth2 (1.1.0)
  faraday (>= 0.8, < 0.10)
  jwt (~> 1.0, < 1.5.2)
  multi_json (~> 1.3)
  multi_xml (~> 0.5)
  rack (>= 1.2, < 3)
omniauth (1.4.1)
  hashie (>= 1.2, < 4)
  rack (>= 1.0, < 3)
omniauth-oauth2 (1.4.0)
  oauth2 (~> 1.0)
  omniauth (~> 1.2)
omniauth-shopify-oauth2 (1.1.17)
  oauth2 (~> 1.1.0)
  omniauth-oauth2 (~> 1.2)
pry (0.10.4)
  coderay (~> 1.1.0)
  method_source (~> 0.8.1)
  slop (~> 3.4)
puma (3.7.0)
rack (1.6.5)
rack-cache (1.6.1)
  rack (>= 0.4)
rack-test (0.6.3)
  rack (>= 1.0)
rails (4.2.7.1)
  actionmailer (= 4.2.7.1)
  actionpack (= 4.2.7.1)
  actionview (= 4.2.7.1)
  activejob (= 4.2.7.1)
  activemodel (= 4.2.7.1)
  activerecord (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  bundler (>= 1.3.0, < 2.0)
  railties (= 4.2.7.1)
  sprockets-rails
rails-deprecated_sanitizer (1.0.3)
  activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
  activesupport (>= 4.2.0.beta, < 5.0)
  nokogiri (~> 1.6)
  rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
  loofah (~> 2.0)
rails-observers (0.1.2)
  activemodel (~> 4.0)
railties (4.2.7.1)
  actionpack (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  rake (>= 0.8.7)
  thor (>= 0.18.1, < 2.0)
rake (12.0.0)
redis (3.3.3)
redis-actionpack (5.0.1)
  actionpack (>= 4.0, < 6)
  redis-rack (>= 1, < 3)
  redis-store (>= 1.1.0, < 1.4.0)
redis-activesupport (5.0.1)
  activesupport (>= 3, < 6)
  redis-store (~> 1.2.0)
redis-namespace (1.5.2)
  redis (~> 3.0, >= 3.0.4)
redis-rack (1.6.0)
  rack (~> 1.5)
  redis-store (~> 1.2.0)
redis-rack-cache (2.0.0)
  rack-cache (~> 1.6.0)
  redis-store (~> 1.2.0.pre)
redis-rails (5.0.1)
  redis-actionpack (~> 5.0.0)
  redis-activesupport (~> 5.0.0)
  redis-store (~> 1.2.0)
redis-store (1.2.0)
  redis (>= 2.2)
sass (3.4.23)
sass-rails (5.0.6)
  railties (>= 4.0.0, < 6)
  sass (~> 3.1)
  sprockets (>= 2.8, < 4.0)
  sprockets-rails (>= 2.0, < 4.0)
  tilt (>= 1.1, < 3)
shopify_api (4.3.5)
  activeresource (>= 3.0.0)
  rack
shopify_app (7.2.3)
  omniauth-shopify-oauth2 (~> 1.1.11)
  rails (>= 4.2.6)
  shopify_api (>= 4.2.2)
slop (3.6.0)
spring (2.0.1)
  activesupport (>= 4.2)
sprockets (3.7.1)
  concurrent-ruby (~> 1.0)
  rack (> 1, < 3)
sprockets-rails (3.2.0)
  actionpack (>= 4.0)
  activesupport (>= 4.0)
  sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.6)
turbolinks (5.0.1)
  turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
  thread_safe (~> 0.1)
uglifier (3.0.4)
  execjs (>= 0.3.0, < 3)

PLATFORMS
  ruby

DEPENDENCIES
  httparty
  jbuilder (~> 2.0)
  jquery-rails
  nokogiri
  pry
  puma
  rails (~> 4.2.6)
  redis
  redis-namespace
  redis-rack-cache
  redis-rails
  sass-rails (~> 5.0)
  shopify_api
  shopify_app (~> 7.2)
  spring
  sqlite3
  turbolinks
  uglifier (>= 1.3.0)

  BUNDLED WITH
   1.13.6

z3yyvxxp

z3yyvxxp1#

  • 如果您使用foreman运行应用程序,就会发生这种情况。这就是工头处理流程的方式。
  • 一旦遇到断点,在foreman接管之前,尽可能快地键入所需的任何内容。

1.不幸的是,您将无法看到您正在键入的内容,但只要您键入正确的内容,您应该能够看到输出。
1.或者,如果这是我的工头命令foreman start -f Procfile.dev
1.转到foreman正在运行的文件(我的是Procfile.dev),并删除运行您的rails服务器的行,对我来说,它类似于web: rails s -b 0.0.0.0现在在不同的终端会话中单独运行rails s -b 0.0.0.0
1.现在您应该可以看到在断点后键入的任何内容,并且可以按照自己的意愿进行调试。注意,如果你花的时间太长,foreman就会接管,你就不能打字了。如果出现这种情况,请重新启动rails服务器。

n3ipq98p

n3ipq98p2#

几年后才遇到的
我最终的解决方案是从foreman切换到overmind。它使用与foreman相同类型的Procfile格式,因此您可能不必在那里进行更改。基本上只需遵循this article here,但总结一下:

  • 安装tmuxovermind
  • 将您的撬/调试器正常放置
  • 在一个单独的shell中,运行overmind connect [name of rails server in your Procfile, probably 'web'],它将允许您连接到您的进程并响应调试提示

唯一的缺点(?如果您不熟悉tmux,并且一次只连接到一个进程,那么需要学习一些导航知识。
或者...如果你只需要运行两三个流程来支持你的应用程序,你可以手动启动它们,而不是使用foreman或overmind。运行rails server可以直接避免这个问题。你也可以使用foreman来启动所有进程 * 除了 * 你的Rails服务器,并手动运行它(如在接受的答案中所建议的)。

相关问题