vscode-ruby version: 0.3.1Make sure you have ruby, ruby-debug-ide and ruby-debug-basex19 installed before submitting your issue -- thank you !
Debugging a local script to work
Uncaught exception: cannot load such file -- some_gem/version
/Users/d/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/d/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/d/work/some_gem/lib/some_gem.rb:1:in `<top (required)>'
/Users/d/.rbenv/versions/2.3.0/bin/rdebug-ide:23:in `load'
/Users/d/.rbenv/versions/2.3.0/bin/rdebug-ide:23:in `<main>'
/Users/d/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- some_gem/version (LoadError)
Looks like this debugger extension has no concept of bundler? 'some_gem' is a gem that is installed in the current directory. Bundler output:
Using some_gem 0.1.0 from source at``.
The correct thing would be to run "bundle exec
@dvelitchkov thanks for reporting it. Yes we should support bundler as it's supported in RubyMine. I'm considering to add a new boolean option, maybe called bundler, to make this optional.
@dvelitchkov, @rebornix, I can add this option now. I've got a couple of minutes to spare. @rebornix, I'll leave it to you to merge and release.
@HookyQR go ahead. The only thing we need to take care of is rdebug-ide requires the absolute path of bundle if it's not in your system path.
FYI @dvelitchkov, I use rbenv, and I don't have any problems running under 1.9.3, 2.0.0, 2.1.2 and 2.3.0, as long as the relevant gems are installed for each (ruby-debug-ide for all, ruby-debug-base19x for 1.9.3, and debase for 2.x).
@rebornix, I'll add 'pathToBundle', and 'pathToRDebug' options as well.
Sure, these two args should be enough now. We can add auto detection as RubyMine does later.
Can I add RVM to the list. Thanks
I'm confused about the how this is supposed to work. I see in package.json that these settings are available for the attach debug type. But in the code in ruby.ts they are used when a launch. Were they configured in the wrong place? Putting them under launch makes the most sense to me since you are launching bundle install.
@penngrove go ahead if you are willing to contribute :+1:
@mhedgpeth thanks for pointing this out. It's a valid bug!
Thanks so much for fixing it @rebornix. Once it's available on the marketplace I'll be happy to test it. When does that happen in your process?
@mhedgpeth I've released the latest version, have a try and let me know it works from your side 馃槃
Sorry about that folks. Seems I was rushing a little when I added that change. Right stuff, wrong place.
@penngrove the new options for the launch config should meet your needs.
{
"pathToBundler": "{actual/path/to/}bundle",
"pathToRDebugIDE": "{actual/path/to/}rdebug-ide",
"useBundler": true | false
}
rvm adds it's paths to the PATH environment variable and may not be doing so before you start VSCode (or where you start it from). Assuming everything is set up correctly (you have ruby-debug-ide installed for the ruby you're using) you should be able to type which rdebug-ide in a terminal to find the string to put in the "pathToRDebugIDE" option.
If you're using bundle, you should use the other two options instead as bundler will take care of all of your dependancies for you.
Right now the feature doesn't work for me (let me know if I should move this to a bug). Debugging the inspec ruby gem I get this error:
Debugger terminal error: Process failed: spawn bundle ENOENT
And this is my config:
{
"version": "0.2.0",
"configurations": [
{
"name": "inspec exec examples/profile/controls/example.rb",
"type": "Ruby",
"request": "launch",
"program": "inspec exec examples/profile/controls/example.rb",
"useBundler": true,
"pathToBundle": "C:/opscode/chefdk/embedded/bin/bundle",
"showDebuggerOutput": true,
"pathToRDebugIDE": "c:/users/michael/appdata/local/chefdk/gem/ruby/2.1.0/bin/rdebug-ide"
}
]
}
As you can see I'm using the embedded version of ChefDK on a Windows 7 machine. Again, let me know if I should file a separate issue for it. I'd also be happy to add more logging to see what is happening, just let me know what I can do.
Sorry, another typo, pathToBundle should be pathToBundler. Will fix the typo in the options tree. Can you add the r and let me know how that goes please. If it doesn't work, try splitting your program to:
"program": "inspec",
"args": ["exec", "examples/profile/controls/example.rb"],
If that still doesn't work ... um ... I'll have to have a better look.
Note that this issue should disappear when I've replaced the debugger, assuming this doesn't get rid of it.
It took me a while to get back to this due to having to reimage my machine. It still doesn't appear to work in the latest version. My config is:
{
"version": "0.2.0",
"configurations": [
{
"name": "inspec exec examples/profile/controls/example.rb",
"type": "Ruby",
"request": "launch",
"program": "inspec",
"args": ["exec", "examples/profile/controls/example.rb"],
"useBundler": true,
"pathToBundler": "C:/opscode/chefdk/embedded/bin/bundle",
"showDebuggerOutput": true,
"pathToRDebugIDE": "c:/users/michael/appdata/local/chefdk/gem/ruby/2.1.0/bin/rdebug-ide"
}
]
}
In the terminal I get a similar message:
Debugger terminal error: Process failed: spawn C:/opscode/chefdk/embedded/bin/bundle ENOENT
If you're changing the debugger, I'm happy to wait for it, I just thought I would give you an update.
@mhedgpeth I'd like to give ChefDK a try and see if I can repro.
I suppose I found the root cause, on Windows the bundle executable is bundle.bat, so change your pathToBundler to "C:/opscode/chefdk/embedded/bin/bundle.bat". Have a try.
Maybe this can save someone else a headache... To get RVM to work you likely have to use the path to the wrappers as per: http://stackoverflow.com/a/26370576/194128
The setup that I eventually got working was:
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rspec",
"useBundler": true,
"pathToBundler": "/Users/<your user>/.rvm/gems/ruby-2.3.0/wrappers/bundle",
"showDebuggerOutput": true,
"pathToRDebugIDE": "${workspaceRoot}/bin/rdebug-ide",
"args": [
"-I",
"${workspaceRoot}"
]
},
Note that as mpapis says on Stack Overflow that you need to replace the bin with wrappers from:
> which bundle
/Users/<your user>/.rvm/gems/ruby-2.3.0/bin/bundle
So you would use:
/Users/<your user>/.rvm/gems/ruby-2.3.0/wrappers/bundle
How do you get rdebug-ide installed in "${workspaceRoot}/bin/rdebug-ide". Mine is installed in /home/username/.rvm/gems/ruby-2.4.1/bin/rdebug-ide
When I configure it as this:
"pathToRDebugIDE": "/home/username/.rvm/gems/ruby-2.4.1/bin/rdebug-ide",
I receive the message:
can't find executable rdebug-ide (Gem::Exception)
@Dee-2015 you need to put that into your gem file. My suggestion is putting it in your development section.
@rebornix Thank you. That helped indeed to get me a step further. Still struggling with the following:
bundler: failed to load command: /home/username/code/ruby_app/bin/rdebug-ide (/home/username/code/ruby_app/bin/rdebug-ide)
The path /home/username/code/ruby_app/bin/rdebug-ide is valid. Running /home/username/code/ruby_app/bin/rdebug-ide -v from the terminal returns:
Using ruby-debug-base 0.2.2.beta10
@Dee-2015 do you mind sharing your launch.json then I can have a good idea with that? Can you run ./bin/bundle exec /home/username/code/ruby_app/bin/rdebug-ide script.rb to see if make any difference?
@rebornix Sure, thank you.
{
"name": "RSpec - active only2",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rspec",
"pathToRDebugIDE": "${workspaceRoot}/bin/rdebug-ide",
"pathToBundler": "/home/username/.rvm/gems/ruby-2.4.1/wrappers/bundle",
"useBundler": true,
"args": [
"-I",
"${workspaceRoot}",
"${file}"
]
}
How do you get rdebug-ide installed in "${workspaceRoot}/bin/rdebug-ide".
It not only needs to be in your gemfile, but you will also have to at least run:
bundle install --binstubs
If not all of:
bundle install --binstubs --path vendor/bundle
This will create the bin file you need. Note if you don't want to check in specific files, update your .gitignore file accordingly.
Also as long as I am here, since my previous comment, I decided to make my launch.json more portable from one machine to the next I have started using:
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rspec",
"useBundler": true,
"pathToBundler": "${env.HOME}/.rvm/gems/${env.rvm_ruby_string}/wrappers/bundle",
"showDebuggerOutput": true,
"pathToRDebugIDE": "${workspaceRoot}/bin/rdebug-ide",
"args": [
"-I",
"${workspaceRoot}"
]
},
NOTE: I am using rvm and the original question was on rbenv, but I think it should be similar.
@aaronblythe thank you, it's pretty helpful to all rvm/rbenv users.
@aaronblythe @rebornix Thank you both. Got it figured out. Adding the gems to the Gemfile was the first step in getting it to work.
Running ./bin/bundle exec /home/username/code/ruby_app/bin/rdebug-ide script.rb worked.
So the message:
bundler: failed to load command: /home/username/code/ruby_app/bin/rdebug-ide (/home/username/code/ruby_app/bin/rdebug-ide)
was triggered by something else. As far as I can see now, it was triggered by another Gem that was/is incompatible with my rails version.
So short recap: you helped me in getting the debugger to work with vscode in combination with rvm and bundler. (Now I still need to fix the problem with my other Gem).
Most helpful comment
Maybe this can save someone else a headache... To get RVM to work you likely have to use the path to the
wrappersas per: http://stackoverflow.com/a/26370576/194128The setup that I eventually got working was:
Note that as mpapis says on Stack Overflow that you need to replace the
binwithwrappersfrom:So you would use: