VSCodeでデバッグ - osamaster2cn/muscle_museum GitHub Wiki
Ruby on Railsの設定
- Gemfileに以下の2行追加
gem "ruby-debug-ide", "~> 0.7.2"
gem "debase", "~> 0.2.4.1"
- gemをインストール
bundle install
- springのログを吐く??? bundle exec spring binstub --all
VS Codeの設定
- ext install Rubyで最初に出てくる拡張機能のRubyを追加
- VS Codeのデバッグモードより、構成ファイルを生成。この時Rubyを選択 .vscode/launch.jsonが作成されるので、以下のようにrdebug-ideの実行設定を行う
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for rdebug-ide",
"type": "Ruby",
"request": "attach",
"cwd": "${workspaceRoot}",
"remoteHost": "127.0.0.1",
"remotePort": "1234",
"remoteWorkspaceRoot": "${workspaceRoot}",
"useBundler": true
}
]
}
デバッグ実行方法
- rdebug-ideの起動
bundle exec rdebug-ide --host 127.0.0.1 --port 1234 --dispatcher-port 26162 -- bin/rails s
- VS Codeのデバッグビューに切り替えてデバッグの実行を押下
参考リンク
Rails×VSCodeのススメ 〜インストールからブレークポイント利用まで〜 Visual Studio Codeを使ってRailsをデバッグ実行してみよう