如何在 MacOS 上的 VS Code 上的不同端口(非默认端口 3000)上调试 Rails 应用程序

Key*_*007 4 macos ruby-on-rails visual-studio-code

我在 MacOS Sierra 上并使用 rbenv。

这是我的 Rails 服务器配置:

{
    "name": "Rails server",
    "type": "Ruby",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "useBundler": true,
    "program": "${workspaceRoot}/bin/rails",
    "args": [
        "server"
    ]
}
Run Code Online (Sandbox Code Playgroud)

我已经为“args”键尝试了以下值:

"args": [
    "server",
    "-p 4002"
]
Run Code Online (Sandbox Code Playgroud)

但我会收到以下错误:

Exiting
bundler: failed to load command: rdebug-ide (/Users/knockycode/vendor/bundle/bin/rdebug-ide)
Uncaught exception: cannot load such file -- rack/handler/-p 4002
Run Code Online (Sandbox Code Playgroud)

Key*_*007 7

我发现它-p 4002包含两个参数:-p标志和4002标志值;这不是一个完整的论点。

工作配置:

{
    "name": "Rails server",
    "type": "Ruby",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "useBundler": true,
    "program": "${workspaceRoot}/bin/rails",
    "args": [
        "server",
        "-p",
        "4002"
    ]
}
Run Code Online (Sandbox Code Playgroud)