DEV Community

Discussion on: Debugging Ruby in VS Code

Collapse
 
karuppasamy profile image
Karuppasamy M

There are more here debugging-Ruby-on-Rails for jRuby, Docker, etc.

Collapse
 
dnamsons profile image
Dāvis Namsons • Edited

I was about to expand this article on launching the debugger directly from VS Code(instead of attaching it) but this is way more detailed than what I would've written, nice work!
You could also contribute this to the vscode-ruby extention's debug guide(launching the debugging session and the example configurations), otherwise this information is quite hard to find.

Collapse
 
andy profile image
Andy Zhao (he/him)

this information is quite hard to find.

Yeah,no kidding. I spent half a day looking how to set up my VS Code for Ruby and Rails, and it's currently still pretty suboptimal compared to Atom. Looking forward to that language server from the Ruby gem though!

Thread Thread
 
dnamsons profile image
Dāvis Namsons • Edited

There seems to be a lack of people interested in developing extensions for Ruby in the VS Code community. I am currently learning some TypeScript to remedy that a bit as it seems like most Ruby extensions are slowly dying from the lack of contributions. I really like VS Code, it really is a shame that Microsoft isn't maintaining Ruby like they are maintaining Python/Go/etc. I might even go over to being a vim purist if this goes on(let's hope not)
What features are you lacking compared to atom if i may ask?

Thread Thread
 
andy profile image
Andy Zhao (he/him)

Totally agree with the sentiment that there's a lack of interest in developing Ruby extensions.

I'm not too sure which features I miss from Atom since it's been almost a year since I last used it. I think my major issue with VS Code + Ruby is the slow development of features I expect to be working, like Solargraph or proper syntax highlighting. The latter might be an issue with my theme though.

Since you mentioned vim, I wonder what most Rubyists use for their text editor.

Thread Thread
 
dnamsons profile image
Dāvis Namsons • Edited

It's not just the theme, the problem really lies with the lexer for tokenization of the Ruby syntax, for example:

def method(argument)
  puts argument
end

method argument

This is a valid and widely used way to call a method with just one argument(if I'm not mistaken, RuboCop's default config even throws a warning if parentheses are used), but as you can see, it doesn't get highlighted correctly.

I stumbled across this research by JetBrains a few days ago, it has the statistics of preferred editors for Ruby developers amongst other things.

Collapse
 
senhalil profile image
senhalil

Hello Davis and Mariappan,
Thanks for both of the articles. I read all the guides I can find on internet and still couldn't figure out how to debug within VSCode when ruby code is run over a server generated with rake.

More specifically, we generate our server like this

bundle exec rake server

COUNT=5 QUEUE=* bundle exec rake resque:workers

and submit the jobs as follows so that the workers perform task posted.

curl -X POST --header "Content-Type:application/json" --data @data.json localhost:port/submit.json?api_key...

Actually I cannot even run the Rake example given in the example configurations page.

I would appreciate any help, pointer, direction!

Best,
halil