我正在尝试使用 Visual Studio Code 在 Docker 容器中远程调试 Ruby(on Rails) 代码。
我的机器上没有安装 Ruby,只是在 Docker 中。
程序如下:
bundle exec rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- bin/rails s -b 0.0.0.0
然后“快速调试器(ruby-debug-ide 0.7.0.beta7,debase 0.2.3.beta3,支持文件过滤)监听 0.0.0.0:1234”但是,当我暂停调试时,VSCode 指示正在执行的行。之后我可以跨过去,VARIABLES、WATCH 和 CALL STACK 正在工作。
似乎只有 BREAKPOINTS 不起作用。
这是我的文件(片段):
启动.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for rdebug-ide",
"type": "Ruby",
"request": "attach",
"cwd": "${workspaceRoot},
"remoteHost": "10.0.75.1",
"remotePort": "1234",
"remoteWorkspaceRoot": "/var/work/app",
"showDebuggerOutput": true,
}
]
}
docker -compose.yml:
services:
app:
build: "./app"
depends_on:
- db
ports:
- "3000:3000"
- "1234:1234"
- "26162:26162"
volumes:
- "./app:/var/work"
stdin_open: true
tty: true
Gemfile.lock:
ruby-debug-ide (0.7.0)
debase (0.2.4.1)
最佳答案
我的问题已经解决了。
我修改了launch.json,它起作用了。似乎错误的是“cmd”的目录规范。
“cmd”必须设置为 Windows 格式。
供引用,目录结构如下:
product_root
├── .vscode
│ └── launch.json
├── product
│ ├── rails_root
│ │ ├── app
│ │ ├── Gemfile
│ │ ├── etc.
│ └── Dockerfile
└── docker-compose.yml
启动.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for rdebug-ide",
"type": "Ruby",
"request": "attach",
"cwd": "${workspaceRoot}\\product\\rails_root",
"remoteHost": "localhost",
"remotePort": "1234",
"remoteWorkspaceRoot": "/var/work/rails_root"
}
]
}
docker -compose.yml
services:
app:
build: "./product"
depends_on:
- db
ports:
- "3000:3000"
- "1234:1234"
- "26162:26162"
volumes:
- "./product:/var/work"
stdin_open: true
tty: true
关于ruby-on-rails - 在 Docker 容器上进行远程调试时,无法使用 Visual Studio 代码中断任何断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54120989/