2

我正在尝试在 Mac 上的 VSCode 的 Rails 应用程序中设置断点。我正在使用 ASDF 安装 Ruby 等。

VSCode for Rails 中的默认启动配置如下所示:

{
    "name": "Rails server",
    "type": "Ruby",
    "request": "launch",
    "program": "${workspaceRoot}/bin/rails",
    "args": [
        "server"
    ]
}

那失败了,因为 my which railsis Users/timregan/.asdf/shims/rails。但是,如果我"program": "${workspaceRoot}/bin/rails"在 launch.json 中替换为,"program": "/Users/timregan/.asdf/shims/rails"当我尝试启动调试会话时会收到此错误消息:

    未捕获的异常:/Users/timregan/.asdf/shims/rails:3:未知的正则表达式选项 - hbrw
    执行 /opt/homebrew/opt/asdf/libexec/bin/asdf ex...
            ^~~~~~~~~
    /Users/timregan/.asdf/shims/rails:3:语法错误,意外的局部变量或方法,期待“do”或“{”或“(”
    .../opt/asdf/libexec/bin/asdf exec "rails" "$@"
    ... ^~~~

        /Users/timregan/.asdf/installs/ruby/3.0.3/bin/rdebug-ide:25:in `load'
        /Users/timregan/.asdf/installs/ruby/3.0.3/bin/rdebug-ide:25:in `'

使用 ASDF 时,在 VSCode 的 launch.json 中调试 Rails 的正确设置是什么?

4

0 回答 0