Please help me to setup debugger on RubyMine for Mac

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

Hi all,

Trying to revive SURubyDebugger.dylib on SU2018 macOS High Sierra.
First started with:
curl -L https://github.com/SketchUp/sketchup-ruby-debugger/releases/download/1.1.0.0/SURubyDebugger.dylib -o /Applications/SketchUp\ 2018/SketchUp.app/Contents/Frameworks/SURubyDebugger.dylib

This downloaded as expected into the SketchUp Frameworks folder. However, although I’ve had this working on older Sketchup’s some time ago, this time it didn’t seam to do much when I started SketchUp:
open -a /Applications/SketchUp\ 2018/SketchUp.app --args -rdebug “ide port=7000”

So, I’ve recompiled SURubyDebugger.dylib, I accepted Xcode’s suggested changes and fixes regarding MACOSX_DEPLOYMENT_TARGET. Besides some deprecation warmings, the build then succeeded. So I placed my new SURubyDebugger.dylib into the Frameworks folder =>

MacBook-Pro-van-JEROEN:Frameworks jeroentheuns$ ls -la /Applications/SketchUp\ 2018/SketchUp.app/Contents/Frameworks/SURubyDebugger.dylib
-rwxr-xr-x 1 jeroentheuns admin 2500512 12 dec 17:07 /Applications/SketchUp 2018/SketchUp.app/Contents/Frameworks/SURubyDebugger.dylib

Next I’m doing: telnet , launch Sketchup2018 in debug mode and telnet again as follows: (had to brew install telnet first since High Sierra for some reason has dropped including that one :frowning: ?

MacBook-Pro-van-JEROEN:~ jeroentheuns$ telnet localhost 7000
Trying ::1…
telnet: connect to address ::1: Connection refused
Trying fe80::1…
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1…
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
MacBook-Pro-van-JEROEN:~ jeroentheuns$ open -a /Applications/SketchUp\ 2018/SketchUp.app --args -rdebug “ide port=7000”
MacBook-Pro-van-JEROEN:~ jeroentheuns$ telnet localhost 7000
Trying ::1…
telnet: connect to address ::1: Connection refused
Trying fe80::1…
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.

Got a connection. That looks fine? However, isn’t SketchUp supposed to startup in ‘beach ball’ frozen state? It launches, but it’s UI is reactive. what does this mean?

I have already setup RubyMine according to Thomas’s guidelines. That part all looks fine, it’s just the SURubyDebugger.dylib itself that seams to cause issues.

Anybody an idea? What am I missing? Any help appreciated.

Starting with 1.1.0.0 the debugger isn’t blocking unless you use the wait flag.
Have you tried connecting with a debugger?

Aha, OK didn’t realize that. Last time I checked, Rubymine didn’t ‘connect’. I’ll give it another try then, cause I assumed by seeing SketchUp being responsive, the debugger was to be blamed. FYI: I am following your excellent guidelines on setting up RubyMine Thomas.

Am I correct that I needed to recompile myself for SU2018 on High Sierra? Or is a compiled SURubyDebugger.dylib provide somewhere? (Since I got a bunch of warnings on deprecated stuff from xcode.)

[SOLVED, see below]

Thomas,
When making the RubyMine IDE SketchUp aware you mention:
But still we are getting some warnings for methods that comes from sketchup.rb in the SketchUp/Tools folders. Let us add that folder as well.

What would be the equivalent path I should add here on mac?



FOUND IT:
“/Applications/SketchUp 2018/SketchUp.app/Contents/Resources/Content/Tools/LangHandler.rb”,
“/Applications/SketchUp 2018/SketchUp.app/Contents/Resources/Content/Tools/Sketchup.rb”,
“/Applications/SketchUp 2018/SketchUp.app/Contents/Resources/Content/Tools/extensions.rb”,
“/Applications/SketchUp 2018/SketchUp.app/Contents/Resources/Content/Tools/langhandler.rb”,

1 Like

Next issue / question configuring SU debugger for RubyMine on mac:

Looking for mac equivalent to the part where you mention excluding ‘Tools/RubyStdLib’
Do I just exclude the entire ruby framwork path? Like so:
/Applications/SketchUp\ 2018/SketchUp.app/Contents/Frameworks/Ruby.framework

Or would you suggest something else?
Here is what I’ve got so far in the RubyMine Project Structure:

And for reference, here is your suggestion on windows. The RubyStdLib is not under the same Tools location on mac…

1 Like

YES, SU DEBUGGER UP AND RUNNING
OK, I’ve got the debugger running:SU2018 on macOS High Sierra, RubyMine 2017.3

It works fine now. Leaving this message here… In case somebody might need help with this in the future, feel free to contact me :slight_smile:

Still not sure about the exclusion path for the ruby standard library though. (see issue above)

Also Rubymine give me this one last warning:


Anybody an idea on that? It points me to the Ruby SDK and Gems pane…

2 Likes

Hm… I’m not sure about that one. Maybe it wants you to pick a Ruby installation that will be driving the debugging?

Hi @jeroen,

I’ve been trying to set up the SU debugger on Mac High Sierra using SketchUp 2018 and RubyMine 2018.1. I’ve tried to follow everything you did in this thread (recompiling, folloiwng all the instructions on the sketchup-ruby-debugger Github site, etc). But no luck.

Do you think you could put together a small working example that I could download? Or perhaps just export your settings from RubyMine for me to inspect?

Anything would be a great help at this poiint.

Thanks!

Ken

UPDATE: Downgrading to RubyMine 2017.3.3 seemed to solve my issues.