LoginSignup
1
1

Ruby AtCoder向けVSCode設定 __debug__(ruby 2.7版)

Last updated at Posted at 2020-11-18

はじめに

以前投稿しました、Ruby AtCoder向けVSCode設定 では、msys2を使用していましたが、最近はrubyinstallerを使用しています。

その rubyinstaller でVSCodeのデバッグ環境が動作するようになりましたので、記録として残したいと思います。

構築順

手前味噌ですが、Ruby AtCoder向けVSCode設定 を合わせて参照願います
VSCode インストール
Ruby インストール
今回は、rubyinstaller-devkit-2.7.2-1-x64.exeを使用しております。
Gem インストール

Gemfile.rb
gem "ruby-debug-ide"
gem "debase"
gem "rcodetools"

VSCode settings.json 設定例

settings.json
{
    "ruby.rctComplete.commandPath": "C:\\Users\\user\\...\\rct-complete.bat"
}

rct-complete.bat のパスを通します

VSCode launch.json 設定例

launch.json
{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Local File",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/main.rb",
            "pathToRDebugIDE": "C:\\Users\\user\\...\\rdebug-ide.bat",
            "pathToBundler": "C:\\Ruby27-x64\\bin\\bundle.bat",
            "useBundler": true,
            "stopOnEntry": true,
            "args": [
                "data.txt"
            ]
        },
    ]
}

rdebug-ide.bat のパスを通します。
bundlerを使用しています。

data.txt

data.txt
2 3

main.rbと同じディレクトリにdata.txtを置きます。

では、F5キーを押下
20201118a.png
20201118b.png
変数表示もバッチリ

まとめ

  • Windows10 の VSCode の Ruby でデバッグができるようになった

参照したサイト
VSCodeでrbenv環境のrubyのデバッグ、コードコンプリートができない
Ruby AtCoder向けVSCode設定

追記(2022-03-09)

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x64-mingw32]

An error occurred while installing debase (0.2.4.1), and Bundler cannot
continue.

Ruby3.0 及び 3.1 ですと debase のインストールに失敗するようですので、AtCoder の Ruby2.7 向けの記事になります。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1