How do you run and debug Ruby on Rails from Visual Studio Code?

前端 未结 3 615
轻奢々
轻奢々 2021-02-07 09:41
  • How can you launch Ruby on Rails using the built-in Visual Studio Code Launch/Debug features?

  • How do you fix the Debugger terminal error: Process

3条回答
  •  粉色の甜心
    2021-02-07 10:08

    I spent most of a day trying to solve this.

    I ended up stripping my launch.json config down to the following:

    "configurations": [
        {
           "name": "Rails server",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "/Users/mitch/.rvm/gems/ruby-2.3.0@gg_portal/bin/rails",
            "args": [
                "server"
            ],
            "useBundler": true,
            "pathToRDebugIDE": "/Users/mitch/.rvm/gems/ruby-2.3.0@gg_portal/gems/ruby-debug-ide-0.6.1",
            "pathToBundler": "/Users/mitch/.rvm/gems/ruby-2.3.0@gg_portal/wrappers/bundle",
            "showDebuggerOutput": true
        }
    
    ]
    

    Firstly, especially if you're using RVM & have different Gemsets, make sure your paths are consistent with the correct Gemset.

    What solved the problem for me was pathToBundler.

    which bundle
    /Users/mitch/.rvm/gems/ruby-2.3.0@gg_portal/bin/bundle
    

    There looks to be some incompatibility around setting the path to the binstubs bundler (shown above) and the bundler pointed to from /wrappers/ (shown below), so changing pathToBundler to:

    "pathToBundler": "/Users/mitch/.rvm/gems/ruby-2.3.0@gg_portal/wrappers/bundle",
    

    solved the problem.

    There is a kind of related discussion here:

    https://github.com/rails/rails/issues/31193
    

    which talks about binstubs though not specifically VSCode & debugging.

提交回复
热议问题