Need to connect to remote server from local SU

I need to connect to remote server from local SU (Pro 2018) to fetch some data required for my scripts.
( I can do that from local Excel to that remote MYSQL database, so

  • server
  • database name
  • user
  • password
    works fine, it should not be an issue)

I try to follow Dan’s recommendation.

Step (2) works fine, result from SketchUp Ruby Console is:

Gem::install "ruby-mysql"
[#<Gem::Specification:0xdb94cf16e0 ruby-mysql-2.9.14>]

Step (3) works fine, result from SketchUp Ruby Console is:

Gem::install "dbi"
[#<Gem::Specification:0xdb953c578c dbi-0.4.5>]

I fail to succed with step (4), result from SketchUp Ruby Console is:

Gem::install "ruby-odbc"
Error: #<Gem::InstallError: The 'ruby-odbc' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
>
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:12:in `rescue in block in <top (required)>'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:4:in `block in <top (required)>'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:275:in `call'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:275:in `block in run_pre_install_hooks'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:274:in `each'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:274:in `run_pre_install_hooks'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:235:in `install'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/request_set.rb:166:in `block in install'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/request_set.rb:150:in `each'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/request_set.rb:150:in `install'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/dependency_installer.rb:394:in `install'
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems.rb:558:in `install'

Then I’ve tried to download ODBC binding for Ruby from
https://rubygems.org/gems/ruby-odbc
as suggested in step (4)
The name of the downloaded file is: “ruby-odbc-0.99999.gem”
I have placed it into “C:\Program Files\SketchUp\SketchUp 2018\Tools\RubyStdLib\rubygems”
( I suspect this is perhaps not the right thing to do with the downloaded file,
since I could not find any other file there with extension name “.gem”)

Still no success, the same error message comes up.
Obviously, I missed some point.
( I skiped step (1) since I try to access remote server where MYSQL is installed, also, I did not download the gems suggested in step 2, and 3.,
since those steps worked without downloading the mentioned files.
Also, I did not dowload DevKit, since I try to install the suggested precompiled gems)

( My Sketchup Pro 2018 version 18.0.16975 64-bit and sketchup-ruby version is 2.2.4 )

Could someone please help?

Correct. This is the wrong place for .gem files. These are archive files BTW.

They go in a “cache” subfolder of the GEM_HOME directory. (The Gem::Install command should have already downloaded it and placed it in the correct folder.)

From SU2018’s Ruby Console find the path by entering …

ENV["GEM_HOME"]

… and you get …

"#{ENV["APPDATA"]}/SketchUp/SketchUp 2018/SketchUp/Gems64"

… which expand to …

"C:/Users/#{ENV["USERNAME"]}/AppData/Roaming/SketchUp/SketchUp 2018/SketchUp/Gems64"

Because, as I said the install command already downloaded the .gem archive, and placed it in the "Gems64/cache" folder. It also placed the .gemspec file for this gem in the "Gems64/specifications" folder. Getting the archive is not the issue.

The reason for the failure is given in the error message …

Error: #<Gem::InstallError: The 'ruby-odbc' native gem requires installed
 build tools.

This gem is a binary gem that needs to be complied on the user’s native platform using build tools.

Normally, you need to install Ruby at the system level (outside of SketchUp, but preferably the same Ruby version.) And then you need to install the Ruby Dev-Kit and follow it’s instructions for getting it setup to work with your system Ruby’s installation. Afterward, you need to install this gem in the system Ruby environment so the Ruby Dev-Kit can compile it. Once done and compiled, you can manually copy the gem into your SketchUp “Gems64/gems” folder. From then on you can use require to load the gem.

@MSP_Greg, did you create some simpler way of doing this from within SketchUp recently ?

Dan,

Yes & no. It makes it a lot easier to use many gem commands. What I haven’t spent any time on is how to handle commands that may require UI responses.

For instance, if one has multiple versions of a gem installed, and one does a gem uninstall without a version option, RubyGems will prompt for which version to uninstall. How to handle that in SU is the problem. I assume I can’t get at the Ruby console input, so I’d have to open an HtmlDialog or something…

There is an easy way to allow a stand-alone Ruby version and SU Ruby to share gems, if that’s helpful… Both versions need to match major/minor.

Start a new thread!!!* This was about SQLite, not MySQL…

You’re on Windows. Have you tried:

Gem.install 'mysql2'

The gem requires libmysql.dll, and it is included in the pre-compiled gem.

The gem did load in SU 2019, but I can’t connect it to anything…