InfoGrab DocsInfoGrab Docs

VS Code 디버깅

요약

이 문서에서는 GitLab Development Kit(GDK)를 사용하여 Visual Studio Code(VS Code)에서 Rails 디버깅을 설정하는 방법을 설명합니다. 아래 예시에는 rails-web 및 rails-background-jobs에 대한 실행 설정이 포함되어 있습니다.

이 문서에서는 GitLab Development Kit(GDK)를 사용하여 Visual Studio Code(VS Code)에서 Rails 디버깅을 설정하는 방법을 설명합니다.

설정#

아래 예시에는 rails-webrails-background-jobs에 대한 실행 설정이 포함되어 있습니다.

  • gitlab 폴더 내에서 gem install debug를 실행하여 debug gem을 설치합니다.

  • VS Code에 rdbg 디버거 유형 지원을 추가하려면 VS Code Ruby rdbg Debugger 확장을 설치합니다.

  • VS Code를 통해 GitLab 및 관련 Ruby Rails/Sidekiq 프로세스를 자동으로 중지하고 시작하려는 경우, .vscode/tasks.json 파일의 설정에 다음 VS Code 태스크를 추가할 수 있습니다:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "start rdbg for rails-web",
      "type": "shell",
      "command": "gdk stop rails-web && GITLAB_RAILS_RACK_TIMEOUT_ENABLE_LOGGING=false PUMA_SINGLE_MODE=true rdbg --open -c bin/rails server",
      "isBackground": true,
      "problemMatcher": {
        "owner": "rails",
        "pattern": {
          "regexp": "^.*$",
        },
        "background": {
          "activeOnStart": false,
          "beginsPattern": "^(ok: down:).*$",
          "endsPattern": "^(DEBUGGER: wait for debugger connection\\.\\.\\.)$"
        }
      }
    },
    {
      "label": "start rdbg for rails-background-jobs",
      "type": "shell",
      "command": "gdk stop rails-background-jobs && rdbg --open -c bundle exec sidekiq",
      "isBackground": true,
      "problemMatcher": {
        "owner": "sidekiq",
        "pattern": {
          "regexp": "^(DEBUGGER: wait for debugger connection\\.\\.\\.)$"
        },
        "background": {
          "activeOnStart": false,
          "beginsPattern": "^(ok: down:).*$",
          "endsPattern": "^(DEBUGGER: wait for debugger connection\\.\\.\\.)$"
        }
      }
    }
  ]
}
  • .vscode/launch.json 파일에 다음 설정을 추가합니다:
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "rdbg",
      "name": "Attach rails-web with rdbg",
      "request": "attach",

      // remove the following "preLaunchTask" if you do not wish to stop and start
      // GitLab via VS Code but manually on a separate terminal.
      "preLaunchTask": "start rdbg for rails-web"
    },
    {
      "type": "rdbg",
      "name": "Attach rails-background-jobs with rdbg",
      "request": "attach",

      // remove the following "preLaunchTask" if you do not wish to stop and start
      // GitLab via VS Code but manually on a separate terminal.
      "preLaunchTask": "start rdbg for rails-background-jobs"
    }
  ]
}

VS Code Ruby 확장이 올바른 Ruby 설치 경로와 적절한 rdbg 명령을 찾지 못하는 경우가 있을 수 있습니다. 이 경우 위의 실행 설정에 "rdbgPath": "/home/user/.asdf/shims/(asdf를 사용하는 경우)를 추가하세요.

디버깅#

사전 요구사항#

  • 실행 중인 GDK 인스턴스가 있어야 합니다.

디버깅을 시작하려면 다음 중 하나를 수행합니다:

  • F5를 누릅니다.

  • Debug: Start Debugging 명령을 실행합니다.

  • 실행 및 디버그 뷰를 열고, 실행 프로필 중 하나를 선택한 다음 Play( play )를 선택합니다.

VS Code 디버깅

GitLab v19.1
원문 보기
요약

이 문서에서는 GitLab Development Kit(GDK)를 사용하여 Visual Studio Code(VS Code)에서 Rails 디버깅을 설정하는 방법을 설명합니다. 아래 예시에는 rails-web 및 rails-background-jobs에 대한 실행 설정이 포함되어 있습니다.

이 문서에서는 GitLab Development Kit(GDK)를 사용하여 Visual Studio Code(VS Code)에서 Rails 디버깅을 설정하는 방법을 설명합니다.

설정#

아래 예시에는 rails-webrails-background-jobs에 대한 실행 설정이 포함되어 있습니다.

  • gitlab 폴더 내에서 gem install debug를 실행하여 debug gem을 설치합니다.

  • VS Code에 rdbg 디버거 유형 지원을 추가하려면 VS Code Ruby rdbg Debugger 확장을 설치합니다.

  • VS Code를 통해 GitLab 및 관련 Ruby Rails/Sidekiq 프로세스를 자동으로 중지하고 시작하려는 경우, .vscode/tasks.json 파일의 설정에 다음 VS Code 태스크를 추가할 수 있습니다:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "start rdbg for rails-web",
      "type": "shell",
      "command": "gdk stop rails-web && GITLAB_RAILS_RACK_TIMEOUT_ENABLE_LOGGING=false PUMA_SINGLE_MODE=true rdbg --open -c bin/rails server",
      "isBackground": true,
      "problemMatcher": {
        "owner": "rails",
        "pattern": {
          "regexp": "^.*$",
        },
        "background": {
          "activeOnStart": false,
          "beginsPattern": "^(ok: down:).*$",
          "endsPattern": "^(DEBUGGER: wait for debugger connection\\.\\.\\.)$"
        }
      }
    },
    {
      "label": "start rdbg for rails-background-jobs",
      "type": "shell",
      "command": "gdk stop rails-background-jobs && rdbg --open -c bundle exec sidekiq",
      "isBackground": true,
      "problemMatcher": {
        "owner": "sidekiq",
        "pattern": {
          "regexp": "^(DEBUGGER: wait for debugger connection\\.\\.\\.)$"
        },
        "background": {
          "activeOnStart": false,
          "beginsPattern": "^(ok: down:).*$",
          "endsPattern": "^(DEBUGGER: wait for debugger connection\\.\\.\\.)$"
        }
      }
    }
  ]
}
  • .vscode/launch.json 파일에 다음 설정을 추가합니다:
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "rdbg",
      "name": "Attach rails-web with rdbg",
      "request": "attach",

      // remove the following "preLaunchTask" if you do not wish to stop and start
      // GitLab via VS Code but manually on a separate terminal.
      "preLaunchTask": "start rdbg for rails-web"
    },
    {
      "type": "rdbg",
      "name": "Attach rails-background-jobs with rdbg",
      "request": "attach",

      // remove the following "preLaunchTask" if you do not wish to stop and start
      // GitLab via VS Code but manually on a separate terminal.
      "preLaunchTask": "start rdbg for rails-background-jobs"
    }
  ]
}

VS Code Ruby 확장이 올바른 Ruby 설치 경로와 적절한 rdbg 명령을 찾지 못하는 경우가 있을 수 있습니다. 이 경우 위의 실행 설정에 "rdbgPath": "/home/user/.asdf/shims/(asdf를 사용하는 경우)를 추가하세요.

디버깅#

사전 요구사항#

  • 실행 중인 GDK 인스턴스가 있어야 합니다.

디버깅을 시작하려면 다음 중 하나를 수행합니다:

  • F5를 누릅니다.

  • Debug: Start Debugging 명령을 실행합니다.

  • 실행 및 디버그 뷰를 열고, 실행 프로필 중 하나를 선택한 다음 Play( play )를 선택합니다.