<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Natalia Sergeeva</title>
    <description>The latest articles on Forem by Natalia Sergeeva (@landria).</description>
    <link>https://forem.com/landria</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F47949%2Fac5c0dee-97d4-4b3b-a471-a4675f5d81a9.jpeg</url>
      <title>Forem: Natalia Sergeeva</title>
      <link>https://forem.com/landria</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/landria"/>
    <language>en</language>
    <item>
      <title>Rbenv: Love at first sight while setting up VSCode debugger for RSpec</title>
      <dc:creator>Natalia Sergeeva</dc:creator>
      <pubDate>Wed, 08 Jan 2020 12:36:46 +0000</pubDate>
      <link>https://forem.com/landria/rbenv-love-at-first-sight-while-setting-up-vscode-debugger-for-rspec-1k7m</link>
      <guid>https://forem.com/landria/rbenv-love-at-first-sight-while-setting-up-vscode-debugger-for-rspec-1k7m</guid>
      <description>&lt;p&gt;I had been using RVM to manage Ruby versions since I started my Ruby (and Rails) journey far in 2011. I was pretty happy with it. It did the job well and I didn't even think of trying something else. Even in complex environments with many different MRI and JRuby versions. Until now...&lt;/p&gt;

&lt;p&gt;I use VSCode for coding. It does what I need and it's pretty comfortable to work with (don't blame me, vim Adventists, I like it too, but...). Previously I worked with C# and Microsoft Visual Studio, and I loved its built-in debugger. I use pry and console to debug Ruby code mostly but VSCode has a debugger too. So a couple of days ago, I decided to give it a try. It worked fine on my machine with a couple of MRI Ruby versions installed via RVM but I failed to run it on my office machine with MRI mixed with jRuby of all sorts and colours. I just wanted to run a debugger on a single spec. It sounds to be easy but it wasn't. Every time I fix one issue with paths, gems, whatever, another pops up. I was about to give up. &lt;/p&gt;

&lt;p&gt;Rbenv came for the rescue. I've heard about it before but I didn't realise how cool this tool actually is. It so simple and easy to install and use, and it offers shims which make setting up environments work like a charm. Add configuration for a debugger once, and then just pick any ruby version and everything works with no configuration changes needed. It turned out to be that simple!&lt;/p&gt;

&lt;p&gt;Add to Gemfile:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;group :development, :test do 
  gem "ruby-debug-ide"

  platform :jruby do
    gem "ruby-debug-base"
  end

  platform :ruby do
    gem "debase"
  end
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Install Rbenv, Ruby and gems:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install rbenv
rbenv init
rbenv install 2.6.3
rbenv local 2.6.3
rbenv rehash
gem install bundler 
bundle install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And then add configuration in VSCode: &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug RSpec - open spec file on a certain line",
      "type": "Ruby",
      "request": "launch",
      "cwd": "${workspaceRoot}",
      "useBundler": true,
      "pathToBundler": "&amp;lt;home dir&amp;gt;/.rbenv/shims/bundler",
      "showDebuggerOutput": false,
      "pathToRDebugIDE": "&amp;lt;home dir&amp;gt;/.rbenv/shims/rdebug-ide",
      "program": "&amp;lt;home dir&amp;gt;/.rbenv/shims/spec",
      "args": [
        "${file}:${lineNumber}"
      ]
    }
  ]
}
// You can find paths using `which` command in terminal: `which bundler`, etc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Set breakpoints, open spec file, select spec, and press F5. It works like a charm for me. No dances with a tambourine. Am I happy? Definitely, I am! I'm in love with Rbenv now and will I suggest everybody who is not using it yet to give it a try. You'll like it!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rspec</category>
      <category>vscode</category>
      <category>debugging</category>
    </item>
  </channel>
</rss>
