简体   繁体   English

使用 ruby on rails app running passenger 配置 vimspector

[英]Configuring vimspector with ruby on rails app running passenger

My question is how do i get vimspector running with a ruby on rails app running passenger (I think)我的问题是如何让 vimspector 与 ruby on rails app running passenger 一起运行(我认为)

I'm trying to set up vimspector with some ruby on rails projects I'm working on.我正在尝试在我正在处理的 Rails 项目上使用一些 ruby 设置 vimspector。 Basically the problem is that vimspector doesn't stop at breakpoints in some apps.基本上问题是 vimspector 不会在某些应用程序的断点处停止。 the apps are using passenger.这些应用程序正在使用乘客。 In a very basic sample app vimspector works fine, but not in the ones where i actually need to debug.在一个非常基本的示例应用程序中,vimspector 工作正常,但在我实际需要调试的应用程序中却不行。

Description :描述:

when i call vimspector#Launch all the splits/windows come up, and a passenger application server gets launched.当我调用 vimspector#Launch 时,所有的拆分/窗口都会出现,并且乘客应用程序服务器会启动。 I don't work alone on some projects so i cannot really change this to another one.我不是一个人在某些项目上工作,所以我无法真正将其更改为另一个项目。

I set some breakpoints and do actions that should stop at them but they run through like without a debugger.我设置了一些断点并执行应该在它们处停止的操作,但它们像没有调试器一样运行。 Also nothing except for threads running and the console output of the rails server shows up in the splits.除了正在运行的线程和 rails 服务器的控制台 output 之外,什么也没有显示在拆分中。 In my processes 2 processes show up.在我的流程中,出现了 2 个流程。 Once the Passenger Ruby app and once a node process going to my cust_vscode-ruby directory which is needed for the debugger.一旦 Passenger Ruby 应用程序和一次节点进程将转到调试器所需的我的 cust_vscode-ruby 目录。 The node process has the subprocess rdebug-ide and rdebug-ide has passenger start.节点进程有子进程 rdebug-ide,rdebug-ide 有 passenger start。

As vimspector works fine with the sample rails app, I don't think its a problem of the install or something like that.由于 vimspector 与示例 Rails 应用程序配合良好,我认为这不是安装问题或类似问题。

I tried switching to attach but when configuring it for attach i get an endless loading without getting a timeout in the browser.我尝试切换到附加,但是在将其配置为附加时,我会无休止地加载,而不会在浏览器中超时。 the terminal window where i run rdebug-ide starts of without any repsonse, i launch vimspector and the server is being booted up.我运行 rdebug-ide 的终端 window 在没有任何响应的情况下启动,我启动 vimspector 并且正在启动服务器。 It stops at this however and never goes past booting Run rails server -h for more startup options .但是,它就此停止,并且永远不会超过引导Run rails server -h for more startup options After which passenger normally starts up.之后 passenger 正常启动。 With switching to attach mode only the rdebug controlled rails server shows up in my processes.通过切换到附加模式,只有 rdebug 控制的 rails 服务器出现在我的进程中。

I think this should be possible as i'm usind ruby-debug-ide which is being used by RubyMine on which i could debug the apps running passenger just fine.我认为这应该是可能的,因为我使用的是 RubyMine 使用的 ruby-debug-ide,我可以在上面调试运行 passenger 的应用程序。 I'm pretty sure that is has to do with passenger as calling it up in launch config leads to it escaping and using attach config leads to it blocking the rails server boot.我很确定这与乘客有关,因为在启动配置中调用它会导致它 escaping 并使用附加配置会导致它阻止 Rails 服务器启动。 But I don't know how to fix it.但我不知道如何解决它。

.vimspector.json same for both sample app and actual app : .vimspector.json示例应用程序和实际应用程序相同

{
    "configurations": {
        "rails": {
            "adapter": "cust_vscode-ruby",
            "default": true,
            "configuration": {
                "name": "Debug Rails server",
                "type": "Ruby",
                "request": "launch",
                "cwd": "${workspaceRoot}",
                "pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
                "pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
                "program": "${workspaceRoot}/bin/rails",
                "args": [
                    "server"
                ]
            }
        }
    }
}

vimspector configuration output vimspector 配置 output

Vimspector Debug Info
--------------------------------------------------------------------------------
ConnectionType: job
Adapter: 
--------------------------------------------------------------------------------
{
  "command": [
    "node",
    "/Users/username/.vim/plugged/vimspector/gadgets/macos/cust_vscode-ruby/dist/debugger/main.js"
  ],
  "configuration": {
    "cwd": "/Users/username/Folder/app-name",
    "showDebugOutput": false,
    "trace": false
  },
  "name": "vscode-ruby-debug",
  "env": {},
  "cwd": "/Users/username/Folder/app-name"
}
--------------------------------------------------------------------------------
Configuration: 
--------------------------------------------------------------------------------
{
  "adapter": "cust_vscode-ruby",
  "default": true,
  "configuration": {
    "name": "Debug Rails server",
    "type": "Ruby",
    "request": "launch",
    "cwd": "/Users/username/Folder/app-name",
    "pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
    "pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
    "program": "/Users/username/Folder/app-name/bin/rails",
    "args": [
      "server"
    ]
  }
}
--------------------------------------------------------------------------------
API Prefix: 
Launch/Init: True / True
Workspace Root: /Users/username/Folder/app-name
Launch Config: 
--------------------------------------------------------------------------------
{
  "cwd": "/Users/username/Folder/app-name",
  "showDebugOutput": false,
  "trace": false,
  "name": "Debug Rails server",
  "type": "Ruby",
  "request": "launch",
  "pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
  "pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
  "program": "/Users/username/Folder/app-name/bin/rails",
  "args": [
    "server"
  ]
}
--------------------------------------------------------------------------------
Server Capabilities: 
--------------------------------------------------------------------------------
{
  "supportsConfigurationDoneRequest": true,
  "supportsConditionalBreakpoints": true
}
--------------------------------------------------------------------------------
Line Breakpoints: 
--------------------------------------------------------------------------------
{
  "/Users/username/Folder/app-name/app/controllers/.../somethings_controller.rb": [
    {
      "state": "ENABLED",
      "line": 83,
      "options": {},
      "sign_id": 1,
      "server_bp": {
        "verified": true,
        "line": 83,
        "id": 1
      }
    }
  ]
}
--------------------------------------------------------------------------------
Func Breakpoints: 
--------------------------------------------------------------------------------
[]
--------------------------------------------------------------------------------
Ex Breakpoints: 
None

so i got it to work not with passenger itself.所以我让它不与乘客本身一起工作。

i changed my vimspector config to the following, switching up some paths to the used binaries by trial and error (i think the one that matters is calling the rails binary in the project root).我将我的 vimspector 配置更改为以下内容,通过反复试验将一些路径切换到使用的二进制文件(我认为重要的是在项目根目录中调用 rails 二进制文件)。 The important thing is to call in the args server -u puma .重要的是调用 args server -u puma Make sure to write each part of the command as a single argument.确保将命令的每个部分写为单个参数。 puma being the default rails server (i found it to be in my sample app), so this gets picked up by rdebug-ide and debase. puma 是默认的 rails 服务器(我发现它在我的示例应用程序中),所以它被 rdebug-ide 和 debase 选中。

{ 
    "configurations": { 
            "rails": { 
                    "adapter": "cust_vscode-ruby", 
                    "default": true, 
                    "configuration": { 
                            "name": "Debug Rails server", 
                            "type": "Ruby", 
                            "request": "launch", 
                            "cwd": "${workspaceRoot}", 
                            "pathToBundler": "/Users/username/.rvm/rubies/ruby-RUBYVERSION/bin/bundler", 
                            "pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-RUBYVERSION/gems/ruby-debug-ide-RUBYDEBUGIDEVERSION", 
                            "program": "${workspaceRoot}/bin/rails", 
                            "args": [ 
                                    "server", "-u", "puma" 
                            ] 
                    } 
            } 
    } 

} }

There are some options I found for using passenger, it probably has to do something with writing the config as attach.我发现了一些使用 passenger 的选项,它可能必须通过将配置编写为附加来做一些事情。

What seemed closest ( but it doesn't work ) to the answer seemed to copy the rubymine config that calls:看起来最接近(但它不起作用)的答案似乎复制了调用的 rubymine 配置:

/bin/bash -c "~/.rvm/bin/rvm _RUBYVERSION_ do ~/.rvm/rubies/ruby-_RUBYVERSION_/bin/ruby ~/.rvm/gems/ruby-_VERSION_/gems/ruby-debug-ide-_RUBYDEBUG-IDEVERSION_/bin/rdebug-ide --key-value --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 42371 --host 0.0.0.0 --dispatcher-port 38403 -- ~/Folder/project/bin/rails server -b 0.0.0.0 -p 3000 -e development"

I think a point where it could be failing, and why it's not working is that passenger needs to be set to allow debugging ( PassengerDebugger on ), although i might just be confusing everything here.我认为它可能会失败的一点,以及为什么它不起作用的原因是需要将 passenger 设置为允许调试( PassengerDebugger on ),尽管我可能只是混淆了这里的一切。 However this passenger option is reserved for the Enterprise version ( https://www.phusionpassenger.com/library/admin/apache/debugging_console/ruby/ ).但是,此乘客选项保留给企业版 ( https://www.phusionpassenger.com/library/admin/apache/debugging_console/ruby/ )。 Where this left me off was i launched this debug config but couldn't connect to the socket.这让我失望的是我启动了这个调试配置但无法连接到套接字。 Maybe this is to some security measure i made to tight for my own good on my system or more likely a fault in the config.也许这是为了我自己的系统利益而采取的一些安全措施,或者更可能是配置中的错误。

I think it's possible to attach to the passenger server properly somehow some ideas could maybe be found here but i didn't get anywhere with them.我认为有可能以某种方式正确地连接到乘客服务器,也许可以在这里找到一些想法,但我没有得到任何帮助。 https://mondotondo.com/2012/08/23/how-to-remotely-debug-rails-in-apache-passenger-rubymine/ How can I get ruby-debug-ide to work? https://mondotondo.com/2012/08/23/how-to-remotely-debug-rails-in-apache-passenger-rubymine/ 如何让 ruby-debug-ide 工作?

If you are struggeling like me with this, hang in there you will get it some day!如果你像我一样为此苦苦挣扎,坚持下去,总有一天你会得到它的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM