使用Ruby在Rails应用程序上配置Vimspector运行乘客

发布于 2025-01-20 05:36:39 字数 4657 浏览 3 评论 0原文

我的问题是如何通过Ruby on Rails应用程序运行乘客(我认为)

我试图用一些Ruby在正在进行的Rauds Projects上设置Vimspector。基本上问题是,Vimspector在某些应用程序中不会停止。这些应用程序正在使用乘客。在一个非常基本的示例应用程序中,vimspector可以正常工作,但在我实际需要调试的应用程序中效果不佳。

Description

当我调用Vimspector#启动所有拆分/窗口时,乘客应用程序服务器服务器将启动。我不独自在某些项目上工作,所以我无法真正将其更改为另一个项目。

我设置了一些断点,并采取应停止的操作,但它们贯穿了,而没有调试器。此外,除了螺纹运行和Rails服务器的控制台输出外,没有什么。在我的过程中,出现了2个过程。一旦乘客Ruby应用程序和一个节点进程转到我的Cust_vscode-Ruby目录,该目录是调试器所需的。节点过程具有子过程Rdebug-ide,Rdebug-ide具有乘客的起点。

由于Vimspector可以在样品导轨应用程序中运行良好,因此我认为这不是安装或类似的问题。

我尝试切换到附件,但是在将其配置为附件时,我会在浏览器中获得无尽的加载。我运行rdebug-ide的终端窗口在没有任何repsonse的情况下开始,我启动了Vimspector,并且正在启动服务器。但是,它停止了,但永远不会超过启动运行Rails Server -H以获取更多启动选项。之后,乘客通常开始。通过切换到附加模式,仅RDEBUG控制的导轨服务器显示在我的流程中。

我认为这应该是可能的,因为我是usind ruby​​-debug-ide,rubymine正在使用它,我可以很好地调试运行乘客的应用程序。我敢肯定,这与乘客有关,因为在启动配置中调用它,并使用附加配置引线阻止了Rails Server启动。但是我不知道该如何解决。

.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配置输出

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

My question is how do i get vimspector running with a ruby on rails app running passenger (I think)

I'm trying to set up vimspector with some ruby on rails projects I'm working on. Basically the problem is that vimspector doesn't stop at breakpoints in some apps. 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.

Description:

when i call vimspector#Launch all the splits/windows come up, and a passenger application server gets launched. 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. In my processes 2 processes show up. Once the Passenger Ruby app and once a node process going to my cust_vscode-ruby directory which is needed for the debugger. The node process has the subprocess rdebug-ide and rdebug-ide has 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.

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. It stops at this however and never goes past booting Run rails server -h for more startup options. After which passenger normally starts up. With switching to attach mode only the rdebug controlled rails server shows up in my processes.

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. 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. But I don't know how to fix it.

.vimspector.json
same for both sample app and actual app :

{
    "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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹雪碎 2025-01-27 05:36:39

所以我让它工作而不是与乘客本身一起工作。

我将 vimspector 配置更改为以下内容,通过反复试验将一些路径切换到所使用的二进制文件(我认为重要的是在项目根目录中调用 Rails 二进制文件)。 重要的是调用参数服务器 -u puma。确保将命令的每个部分写为单个参数。 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" 
                            ] 
                    } 
            } 
    } 

我发现了一些

使用乘客的选项,它可能必须通过将配置写入附加来执行某些操作。

看起来最接近答案的(但它不起作用)似乎复制了调用的 ruby​​mine 配置:

/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"

我认为它可能会失败,而它不起作用的原因是乘客需要设置为允许调试(PassengerDebugger on),尽管我可能只是混淆了这里的所有内容。但是,此乘客选项是为企业版本保留的(https://www. phusionpassenger.com/library/admin/apache/debugging_console/ruby/)。
这让我失望的是我启动了这个调试配置但无法连接到套接字。也许这是我为了自己的系统利益而采取的一些安全措施,或更可能是配置中的错误。

我认为可以以某种方式正确连接到乘客服务器,也许可以在这里找到一些想法,但我没有得到任何结果。
https://mondotondo .com/2012/08/23/how-to-remotely-debug-rails-in-apache-passenger-rubymine/
如何让 ruby​​-debug-ide 工作?

如果你像我一样为此苦苦挣扎,坚持下去,总有一天你会得到它的!

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). The important thing is to call in the 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.

{ 
    "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.

What seemed closest (but it doesn't work) to the answer seemed to copy the rubymine config that calls:

/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. However this passenger option is reserved for the Enterprise version (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?

If you are struggeling like me with this, hang in there you will get it some day!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文