2

I have been trying to set up the debugger, or something alike, so I can test my code while I start to learn the language ruby.

I have read dozens of tutorials, and still now I did not manage to understand how to get this to work.

  1. I have downloaded the two gems indicated + ruby extension for vscode, as per recommended in several tutorials.
gem install ruby-debug-ide
gem install debase
  1. I have created a vs.code file with a {}launch.json file inside.

  2. on the {} launch.json file I have typed the following code:

"version": "0.2.0",
"configurations": [

  {
    "name": "Rails server",
    "type": "Ruby",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "program": "${workspaceRoot}/bin/rails",
    "args": ["server"]
  }
]
}

When I run the debugger I get the following feedback on the DEBUG CONSOLE: Debugger terminal error: Process failed: spawn rdebug-ide ENOENT

I am looking for a solution that lets me see the output of functions, variables, etc, like we do on javascript, using console.log(). I guess it is the equivalent to puts(), or prints() on ruby.

Please let me know if I have to set something else besides the debugger in order to have specific output of my code, as per stated above.

Really desperate with this at this point. Thanks in advance to all!

Arp
  • 979
  • 2
  • 13
  • 30
  • Did you read through the comments here? Make sure you can run it manually from the command line first: https://github.com/rubyide/vscode-ruby/issues/113 – Casper Oct 18 '19 at 01:03
  • I have checked if my env is correct, but I cannot understand this quite well yet... ```"env": { "PATH": "/Users/Dev/.rvm/gems/ruby-2.6.3/bin:/Users/Dev/.rvm/gems/ruby-2.6.3@global/bin:/Users/Dev/.rvm/rubies/ruby-2.6.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/Dev/.rvm/bin", "GEM_HOME": "/Users/Dev/.rvm/gems/ruby-2.6.3", "GEM_PATH": "/Users/Dev/.rvm/gems/ruby-2.6.3:/Users/Dev/.rvm/gems/ruby-2.6.3@global", "RUBY_VERSION": "ruby-2.6.3"``` } – Arp Oct 18 '19 at 01:26
  • Also see this: https://stackoverflow.com/questions/51722136/how-do-you-run-and-debug-ruby-on-rails-from-visual-studio-code/54477794#54477794 – Casper Oct 18 '19 at 01:36
  • how do I discover the path of ruby-debug-ide so I can set it at launch file? – Arp Oct 18 '19 at 01:37
  • @casper how do I check if I can run it from the command line? Thanks for the support – Arp Oct 18 '19 at 01:37
  • 1
    Type `rdebug-ide some_ruby_test_file.rb` in the console. – Casper Oct 18 '19 at 01:39
  • @Casper it did not return the path itself. It returned the following instead: ```Fast Debugger (ruby-debug-ide 0.7.0, debase 0.2.4.1, file filtering is supported) listens on 127.0.0.1:1234``` – Arp Oct 18 '19 at 01:53
  • Ok that's good. It means the debugger works. If you want the path to it you can type `which rdebug-ide`. Since it works in the console, something must be wrong with the VSCode setup. Look at the SO question I linked above, it contains some troubleshooting tips. – Casper Oct 18 '19 at 02:00
  • @Casper thanks for your reply. I have been trying to figure out how Mitch (his answer) did it on the link you've passed me. But it's all a quite confusing as I am new to all of this =) – Arp Oct 18 '19 at 02:10
  • Also look at the answer above by janniks. It has some troubleshooting tips. – Casper Oct 18 '19 at 02:27
  • @Casper thanks... on my first comment above is the result of step 02 on janniks reply: ```printf "\n\"env\": {\n \"PATH\": \"$PATH\",\n \"GEM_HOME\": \"$GEM_HOME\",\n \"GEM_PATH\": \"$GEM_PATH\",\n \"RUBY_VERSION\": \"$RUBY_VERSION\"\n}\n\n"``` After doing that, what do I do next? – Arp Oct 18 '19 at 02:51
  • I get kind of lost. Is probably something that I am overlooking as I am new to this – Arp Oct 18 '19 at 02:52

0 Answers0