Please help me to setup debugger on RubyMine for Mac

At this time just paste the startup line in the OS X terminal.

We should find a way to automate that as well. We like automation. :slight_smile:

It’s possible to do, but we hadn’t the time yesterday to figure it out. If we found it, I let you know.

1 Like

Hi all,

I tried tt_su’s hints (adapted to my Windows 8 PC setup, that is), but didn’t succeed: SketchUp just sits there and seems to be frozen.

Here is what I am doing:

  1. installed SketchUp 2014 to “D:\SketchUp 2014\SketchUp.exe”
  2. installed RubyMine 6 to “C:\Program Files (x86)\JetBrains\RubyMine
    6.0.1\bin\rubymine.exe” & made sure that it (and Ruby’s debugger) works flawlessly
  3. installed SketchUp-Ruby-API Debugger from GitHub - SketchUp/sketchup-ruby-debugger: Ruby API debugger for SketchUp 2014 and later. by putting the (32 bit-) version of “SURubyDebugger.dll” into the respective SketchUp root directory, that is: “D:\SketchUp 2014\SURubyDebugger.dll”
  4. made a small test-script, containing just the following:

puts “Hello World!”
Sketchup.active_model.entities.add_line [0,0,0], [9,9,9]
puts “thats all folks!”

This script I made inside RubyMine into a new RubyMine project “SketchUpTest” as a file named “HelloSketchUpWorld.rb”, that is:

“C:\Users\kr\RubymineProjects\SketchUpTest\HelloSketchUpWorld.rb”

As tt_su suggested, I created a “Ruby remote debug” entry. I gave it the „Name“ = „SketchUp 2014“, set:

  • remote port = 7000,
  • local port = 26162 (that is, its “magic” default)
  • remote root = local root = "C:\Users\kr\RubymineProjects\SketchUpTest“ (that is, to where my HelloSketchUpWorld.rb file is lcoated

-Perhaps that is already wrong and in conflict with SU’s defaults(?). Anyway, I adapted the VBS script to match my instance of Sketchup.exe:

Dim objShell
Set objShell = WScript.CreateObject(“WScript.Shell”)
objShell.Run(“”“D:\SketchUp 2014\SketchUp.exe”" -rdebug ““ide port=7000"””)
Set objShell = Nothing

So far, so good. Some „OK“s later, I’m back in RubyMine’s regular main window. There, a right click on the „SketchUpTest“ project now offers a „Debug SketchUp“ group with my newly created „Invoke SketchUp 2014 Remote Debug“ item in it. Selecting it, the VBS-script starts and shoots up SketchUp 2014, but afterwards, SketchUp just sits there and does… …nothing! Just displays Win 8’s hour-glass, -seems it is waiting forever in remote mode that RubyMine connects.

Alt-Tab back to RubyMine doesn’t help either: wscript.exe tells that it successfully finished to run the VBS, but the HelloSketchUpWorld.rb script is not shown running (no matter whether one has set breakpoints on any of the three code lines in before or not), no console window or whatever else.

-What is wrong with my settings? I guess that the directories might conflict, but am not sure.
I’m happy to write & publish a step-by-step tutorial once I got that beast working, but for the moment being, I’m truly lost… :frowning:

tia,
Kristine

Been a while since I used the debugger now. Just tired it up to test myself. When I used the context menu to launch I saw the same thing - SU started, but it appear to only start SketchUp in debug mode without connecting to it. Not sure why that is.

On the other hand, when I launched from the toolbar it worked fine. I think that one starts the last used debugger. Not sure why there is a difference…

Ah, so I think the menu item refer to the tool that runs before the debugging only. It doesn’t actually launch the debugger.

I confused myself by naming the external tool “Debug SketchUp”. Naming it “Launch SketchUp in Debug Mode” makes it clearer what the different menu items are.

Instead one should select the debug config in the drop down list in the toolbar:

Hei ThomThom,

well… -seems you have confused me, either… :smile:

I tried to follow your steps, but to no avail…

-Here is a (a bit lengthy…) PDF step-by-step approach with screenshots which I took:
http://ul.to/8k823bc5

I’d really like to nail this one down & polish it into a fool-proof tutorial for all here. I’m volunteering for the fool, but’d need one for the proof… :wink:

-Do you see the difference why this works at yours, but not here?

paljon kiitoksia!
Kristine

Can you upload directly to the forum instead of using services that has time-delay and ads to download?

I gave up after 3 ad-popups…

Hi ThomThom,

here we go:
Rubymine and SketchUp Debugger.pdf (900.9 KB)

Tusen takk,
Kristine

Right - did you see my post earlier? (Please help me to setup debugger on RubyMine for Mac - #17 by tt_su)

That menu item you use only launched the external tool that executes the VBS.

Instead you must run the Debug function. Though I’ve not found how to trigger this from the context menu. This appear to only start the local debugger. To start the remote: show the toolbar:

Then pick the Remote Debugger config from the dropdown list:

Then you should be able to launch it from the toolbar:

Hi ThomThom,

I’m coming closer! -Yes, I did read your previous post and tried it, but it didn’t help, SketchUp was still sitting there, comfortably numb…
I gave it another try, and now noticed that RubyMine reported a tiny “Error running SketchUp 2014: Failed to find free socket port for process dispatcher”. -No wonder that SU didn’t made a ■■■■…

So I re-booted the PC -and voila, this time it worked. Once. The 2nd try ends up with the above mentioned error: Not really usable, if one had to re-boot the PC after each and every single debugger run…

But what is worse: While the code does run, the line-break-points don’t trigger (I made every of the 3 lines with a line-break point, but SU just runs the script completely).

Seems that the debugger <-> SketchUp link is still in its infancies. But: I’m on the right track, and xmas time is coming wit ha few days off for experimenting, so I guess I’ll wipe off RubyMine & SketchUp 2014 completely, re-install SketchUp 2015 and give it a try with the 64bit debugger DLL, perhaps this one behaves more gracefully…

(BTW: Are you using the 32bit or 64bit debugger DLL?)

Thanks a lot & Hyvää Joulua!

Hi ThomThom,

meanwhile, I found out two other things:

  • the “failed to find free socket port for process dispatcher” error can be avoided by explicitely stopping the process in RubyMine (“Run” → “Stop”)

And -for something really, really strange-

  • RubyMine (or the debugger?) doesn’t care at all about the directory settings for the .rb-files!

As stated before, my sample script HelloSketchUpWorld.rb sits in the directory

"C:\Users\kr\RubymineProjects\SketchUpTest"

whilst my SketchUp is using its default dir

"C:\Users\kr\AppData\Roaming\SketchUp\SketchUp 2014\SketchUp\Plugins"

In RubyMine’s “Edit Configuration” settings, I thus made “Remote folder” and “Local folder” both point to "C:\Users\kr\RubymineProjects\SketchUpTest" (=as that is where my Ruby-script actually resides!)

Now here is the strange thing: SketchUp neverever uses that path!
Even more strange: It doesn’t complain, but just runs any (!) Ruby file in its Plugins-folder instead! -Yes, you are reading correctly: ANY .rb files there! To be sure about that, I generated 3 files (test1.rb, test2.rb, test3.rb), each with a different single line drawing code inside.

If I now start the debugger by starting HelloSketchUpWorld.rb inside RubyMine as sketched in your last post, it just ignores the Ruby content therein -and instead runs all three (!) test*.rb files consecutively in SketchUp (=resulting in 3 lines being drawn)!

Okay, so I thought, “I use Thomas’ folder settings to the plugin dir instead!” and changed the dirs for remote / local folder to SketchUp’s “plugin” directory. Guess what? -No difference, either!

From that, I derive the following:

  • SketchUp always expects the .rb files in its own plugin
    directory, no matter what one states inside RubyMine anywhere
  • the debugger bridge RubyMine <-> SketchUp is broken, the respective file settings in the “Edit Configuration” are neglected

Thomas: Is your RubyMine setup really such that your source code files are
always in SketchUp’s plugin-directory (or do you have your original
files somewhere else & just copy them manually to SketchUp’s plugin
dir?)
-It is taking me wonder as RubyMine organizes files by projects (e.g.: my sample HelloSketchUpWorld.rb is part of a RubyMine project “SketchUpTest”); so to have more than 1 project == have more than 1 folder and this of course conflicts with the single 1 SketchUp-plugin folder…

I have my extensions in Git repositories located elsewhere on the disk. I then have a loader script in my Plugins folder that adds extra paths to $LOAD_PATH and then loads the root RB files for my extensions.
This is needed to be able to have a Git repo per extension. It also allows me to have a RubyMine project per extension.

I need to re-read your comments again to be sure I fully comprehended it all. Though I have to defer that until another day. Got to head out now.

@bugra, do you have any insight that might help here?

@k_rickards: yes the local and remote folder settings in RubyMine have no effect on where SketchUp loads Ruby code from. I’m not sure why you have that expectation. SketchUp only ever loads Ruby code from where it always does, mainly the Plugins directory in AppData/Roaming.

Hi bugra,

'glad you stepped in & confirm my observations…

I’m not sure why you have that expectation

Well, IMHO, it would be the only chance that debugging SketchUp works in practice:

To use RubyMine, you have your Ruby file(s) in some project directories, but when it comes to actually debug them, they would have to be placed into SketchUp’s plugin dir -how shall this work if there isn’t a way how RubyMine (or whatever IDE) tells SketchUp which common .rb file both the IDE and SU should interact upon? :question:

Note also that even if I do “clone” the .rb file which RubyMine processes into SU’s plugin folder, even that doesn’t work. As I stated, once started by RubyMine’s debug-command, SU just runs all .rb files in its plugin dir…

So I am a bit puzzled how the SU debugger work at all? I’d expect that it interacts with the IDE by exchanging line numbers (?), so as long as the source .rb and its “clone” in SU’s plugin dir are identically, it should work.

-Perhaps you can shade a little light on the working principles SU ↔ debugger behind the scenes; w/o such knowledge, this trial&error is a bit frustrating…

TIA
Kristine

They don’t have to be in the SketchUp plugins folder. You add a RB file in the Plugins folder that adds your external projects to the load path and then require the root RB files. SketchUp then loads them.

Here is an example of one of these loader scripts I use:

#SKETCHUP_CONSOLE.show

# Array of external extension locations:
paths = [
  'C:/Users/Thomas/SourceTree/tt-library-2',
  'C:/Users/Thomas/SourceTree/TestUp2/src',
  'C:/Users/Thomas/SourceTree/SKUI/src',
  #'C:/Users/Thomas/SourceTree/vertex-tools/src',
  'C:/Users/Thomas/SourceTree/vertex-tools',
  'C:/Users/Thomas/SourceTree/bezier-surface/src',
  #'C:/Users/Thomas/SourceTree/catmull-clark-subdivision',
  #'C:/Users/Thomas/SourceTree/guide-tools/src',
  'C:/Users/Thomas/SourceTree/sketchup-stl/src',
  'C:/Users/Thomas/SourceTree/teapot',
  'C:/Users/Thomas/SourceTree/sketchup-attribute-helper/src',
  'C:/Users/Thomas/SourceTree/sketchup-safe-frames/src',
  'C:/Users/Thomas/SourceTree/cleanup',
  #'C:/Users/Thomas/SourceTree/shader-tools/src',
  'C:/Users/Thomas/SourceTree/SpeedUp/src',
  'C:/Users/Thomas/SourceTree/solid-inspector/src',
  'C:/Users/Thomas/SourceTree/SelectionTools/src',
  'C:/Users/Thomas/SourceTree/sketchup-safe-frames/src'
]

# Add all paths to the $LOAD_PATH and collect list of root RB files that should be loaded:
ruby_files = []
for path in paths
  puts path
  $LOAD_PATH << path
  ruby_files_filter = File.join(path, '*.{rb,rbs}')
  ruby_files.concat(Dir.glob(ruby_files_filter).map { |filename|
    File.basename(filename, '.*')
  })
end

for ruby_file in ruby_files
  begin
    require ruby_file
  rescue LoadError
    raise
  end
end

Like Thom said, one way is to have a loader script, which can load any other ruby file from any other location.

But, the IDE can also be pointed to the Plugins folder. As long as you open the same file that SketchUp executes, debugging will work. The IDE and SketchUp exchanges the full paths of the ruby files and line numbers of execution. So they both should point to the same files. IDEs are perfectly capable of opening files from any location in the hard drive, which includes the Plugins folder. So no duplication is necessary. In fact, as you experienced, duplication will break the debugging.

1 Like

Hello bugra,

But, the IDE can also be pointed to the Plugins folder. As long as you open the same file that SketchUp executes, debugging will work. The IDE and SketchUp exchanges the full paths of the ruby files and line numbers of execution.

? How is that? The only way I see how one can instruct the RubyMine IDE to point SU to the project folders is by the “remote folder” and “local folder” paths in the “Edir Configurations” dialog. But that’s exactly what I’m trying all the time, see my previous postings:

remote root = local root = "C:\Users\kr\RubymineProjects\SketchUpTest“ (that is, to where my HelloSketchUpWorld.rb file is lcoated

If I missed something, I’d be glad to hear?..

TIA
Kristine

Well, that is not the SketchUp “Plugins” folder, it is some other folder entirely. Please take a look at the second post in this thread where @tt_su is showing excellent screenshots. He is setting the remote and local root folders to:

C:\Users\username\AppData\Roaming\SketchUp\SketchUp 2014\Plugins

This is the “Plugins” folder SketchUp knows about.

Then put your one and only HelloSketchUpWorld.rb file in there as well. And open that file in the IDE. That’s all !

1 Like