Using SQLite Gem in OSX vs Windows

We have an app that uses SQLite on the user’s local system. In Windows we’ve been able to get a Gem install to work, but it crashes on the Mac no matter which driver we use, 32 bit, 64 bit… doesn’t matter. Has anyone had any experience / luck getting SQLite to work on OSX?

Do you mean that the Gem.install crashes, or that SQLite crashes after successfully installing the Gem? This Gem involves compiled C code. I’ve had difficulties getting C-based Gems to compile within SketchUp in the past.

It’s after the installation; it crashes even when using a pre-built gem
(built for the correct architecture) that has been unpacked into the source
tree. The crash occurs essentially right as the Ruby interpreter goes to
invoke the native code via the FFI.

Using the same pre-built gem from a Ruby 2.0.0 console on the machine,
accesses to the database work fine.

I haven’t had success copy-installing Gems compiled by the native Ruby into SketchUp’s library.

If you didn’t do so, you probably have to compile against the headers and libraries used by SketchUp. I believe they tweaked a few things inside the interpreter to avoid clashes with SketchUp. They are available at

Beyond that, it would take a lot more time than I can spare just now to track this down. Sorry… Perhaps an expert such as ThomThom or Bugra will chime in.

Thanks for the replies. We’re going to try that and I’ll report back what happens.

Using Gems from standalone Ruby with SketchUp Ruby has been a hit and miss in our experience. Don’t have a generic advice on this one I’m afraid. Lots of things in Ruby assumes it’s being run as a console app - which isn’t the case of SketchUp where we wrangled it into a desktop application.

A bit more detail here: I’m the developer who’s been working with Peter on this.

The issue is actually not merely the crash of a gem install; instead, SketchUp crashes entirely (BugSplat) as soon as native Sqlite code is invoked via the FFI from Ruby. This occurs reliably on OSX, but does not occur at all on Windows. I’ve attempted building the sqlite binaries for both 32 and 64-bit architectures, but I’ve not yet attempted building the gem using the headers used by SketchUp, so I’ll give that a try next. Thanks for the link, @slbaumgartner!

1 Like

I was asked on SCF how to do this in pure Ruby. My recommendation:

(1) I believe, You or whomever runs the Server still need to install MySQL:
[url]http://dev.mysql.com/downloads/windows/installer/[/url]

From SketchUp Ruby Console (or a script running in SketchUp’s embedded Ruby):

(2) Gem::install "ruby-mysql"
(Pure-Ruby edition - replaces the C edition named “mysql” gem, that needs compiling.)
source: GitHub - tmtm/ruby-mysql: MySQL connector for Ruby. pure Ruby version.
gem: ruby-mysql | RubyGems.org | your community gem host
doc: File: README — Documentation for mysql (2.9.1)

(3) Gem::install "dbi"
gem: dbi | RubyGems.org | your community gem host
doc: File: README — Documentation for dbi (0.4.5)

(4) Gem::install "ruby-odbc"
gem: ruby-odbc | RubyGems.org | your community gem host
doc: File: README — Documentation for ruby-odbc (0.999991)

Also… have sent corrected URLs to the website hosting the DBI tutorial:

1 Like

@DanRathbun: Why are you talking about MySQL ? I can’t understand how this related to SQLite topic.

Because using the SQLite gem under SketchUp does not work.

Who cares what engine is used to access the data ? If a pure ruby MySQL approach works (where SQLite fails) then my note is relevant.

The information in my post is an alternative. If you do not need it, ignore it and move on.

Wow! I wasn’t criticizing you @DanRathbun, I was just asking you why. Because in my case I do need to use SQLite and MySQL is not an option (too bad, it’s a client requirement).

4 posts were split to a new topic: Need to connect to remote server from local SU