I come to Sketchup development from a background of about 5 years of development in pure Ruby and RoR. I’ve read a few threads on the forums about the trials and tribulations of trying to install gems for plugins, and followed suggestions in threads like this: https://forums.sketchup.com/t/keeping-gems-locally-inside-extension/59436/6
I’m working with a complicated existing codebase on a plugin, and would love to be able to work with my beloved Pry bindings to access program state while developing. There is no need to leave the gem installed outside of the development environment.
I tried including the gem install in a module I’m working with, following the approach in the above thread, and it seemed to install ok, but pry is giving me errors when I try to call it. Here is just the last line of the call stack:
Error: #<NoMethodError: undefined method `sync=' for #<Sketchup::Console:0x007fd0451a84d0>>
/Users/jessefarber/Library/Application Support/SketchUp 2018/SketchUp/Gems/gems/pry-0.11.3/lib/pry/config/default.rb:10:in `block (2 levels) in <class:Default>'`
I am aware that things like matching version numbers can be the issue, but I thought maybe someone here has looked at the ins and outs of getting the Pry gem to work here before. Does anyone have any ideas?
What is Pry ? What does it do ?
Why do you need it during development ?
The error might be due to the fact that SketchUp embedded Ruby redirects $stdin and $stdout to its singleton Sketchup::Console object, referenced by the global constant SKETCHUP_CONSOLE.
Thanks for the reply. In this context, Pry is a debugger that allows you to freeze program state during runtime, e.g. to check variable values interactively, try running other code on the current state, etc. It usually operates through the CLI, but using it in the SketchUp console would be perfectly fine, if I could figure out how to set this up.
I think the debugger hooks are meant for full blown IDEs. ( Corrected by Thomas below. )
At one time I had installed a Notepad++ python extension that added a button which would reload the current rb document into the running SketchUp application process. (But I think this extension by Jim Foltz was PC only.)
You can use it with any editor that support the rdebug-ide gem - either nativly or via extensions.
As for getting gems compiled and installed SketchUp, I’ve typically built them using standalone Ruby (with a matching version as SketchUp’s) and then manually copied them into the SketchUp gems directory.
I think @MSP_Greg have dug deeper into getting the developer kit to work from within SketchUp.
I generally prefer using the Ruby Debugger over Pry. Maybe I just didn’t get the hand of Pry, but you didn’t seem to be able to step through code. With the debugger you easily see the stack, with all the available variables. And you can eval things in the scope of your current breakpoint.
Thanks, that’s helpful. I’ll need to see how to run the ruby debugger, and how to connect it to sublime text. I’d rather not switch my text editor, but I’ve never had to get Sublime Text connected to a port before, and I’m not finding it obvious so far.
Thanks Greg, thanks for helping!
I actually haven’t done that kind of debugging in Sublime before. I’ve generally used a mix of Pry in the CLI, and browser tools for web development.
I’m going to have to set this up in both Mac OS and Windows, but Mac is a little more urgent.
I’d probably be happy to use the debugger mentioned above if I can get it to work… but Windows seems to be a whole other can of worms.
I’d probably be happy to use the debugger mentioned above if I can get it to work
VSCode is cross-platform, and it doesn’t look like you need to compile anything (or install any gems), but yiu do need the files at sketchup-ruby-debugger
I may see if I can get it connected this weekend. FYI, I’m a windows type.