# Vscode-ruby Does Not Find Source When Attaching to a Running Ruby Gem

**URL:** <https://talk.jekyllrb.com/t/vscode-ruby-does-not-find-source-when-attaching-to-a-running-ruby-gem/7231>\
**Category:** Help\
**Created:** [April 12, 2022, 5:37pm UTC](https://talk.jekyllrb.com/t/vscode-ruby-does-not-find-source-when-attaching-to-a-running-ruby-gem/7231 "2022-04-12T17:37:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mslinn](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mslinn/32/2813_2.png) [@mslinn](https://talk.jekyllrb.com/u/mslinn)\
**Post date:** [April 12, 2022, 5:37pm UTC](https://talk.jekyllrb.com/t/vscode-ruby-does-not-find-source-when-attaching-to-a-running-ruby-gem/7231/1 "2022-04-12T17:37:56Z")

</div>

I asked this question on [Stackoverflow](https://stackoverflow.com/questions/71426325/visual-studio-code-does-not-find-source-when-attaching-to-a-running-ruby-gem) and [vscode-ruby](https://github.com/rubyide/vscode-ruby/issues/804) but did not get any responses. Perhaps someone here can help?

Using Visual Studio Code and the [`rebornix.Ruby` extension](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby), `launch` ing a Ruby program for debugging works fine: when execution encounters a break point, the code corresponding to the top of the stack is displayed and variables in scope are also displayed.

However, when debugging a Ruby gem by `attach` ing to a running gem, when execution encounters a break point in the gem, the code corresponding to the top of the stack is not displayed, although the variables in scope are displayed. This is the `launch.json` configuration:

```auto
    {
      "cwd": "${workspaceRoot}",
      "name": "Attach rdebug-ide",
      "request": "attach",
      "remoteHost": "localhost",
      "remotePort": "1234",
      "remoteWorkspaceRoot": "/",
      "restart": true,
      "showDebuggerOutput": true,
      "type": "Ruby",
    },

```

This is the script that runs the [Jekyll gem](https://rubygems.org/gems/jekyll), which Visual Studio Code attaches to:

```auto
bundle exec rdebug-ide \
  --host 0.0.0.0 \
  --port 1234 \
  --dispatcher-port 26162 \
  -- \
    /usr/local/bin/jekyll serve \
      --livereload_port 35721 \
      --force_polling \
      --host 0.0.0.0 \
      --port 4001 \
      --future \
      --incremental \
      --livereload \
      --drafts \
      --unpublished

```

To explain further, the gem’s source code is available locally because it was provided in the gem, in the `lib/` directory, as is normal.

```auto
$ gem info jekyll

***LOCAL GEMS***

jekyll (4.2.2, 4.2.1)
    Authors: Tom Preston-Werner, Parker Moore, Matt Rogers
    Homepage: https://jekyllrb.com
    License: MIT
    Installed at (4.2.2): /home/mslinn/.gems
                 (4.2.1): /home/mslinn/.gems

    A simple, blog aware, static site generator.

$ cd $HOME/.gems/gems/jekyll-4.2.2/lib

$ ls
blank_template/ jekyll/ jekyll.rb site_template/ theme_template/

$ find . -name '*.rb' | wc -l
88

```

How can Visual Studio Code associate the source code for the gem when attaching to its running process?

More detail is available on a [blog post](https://www.mslinn.com/blog/2022/02/21/jekyll-debugging.html#pdb) that I wrote.
