Cannot connect mysql with ruby in sketchup

Hi all,

I was trying to read data from mysql and output it on Sketchup Webdialog with ruby. I have successfully connected ruby with sql, and ruby with sketchup Make. However, the command: require ‘mysql’ always puts a error: LoadError: cannot load such file – mysql, no matter I write this in a ruby file or directly in the ruby console in sketchup UI. Hope to know what can I do to fix this problem. Thx.

The ruby version is 2.1.4,
And mysql is Ver 14.14 Distrib 5.6.22, for osx10.10 (x86_64) using EditLine wrapper
Sketchup is 2015 Make

log below:
require ‘mysql’
Error: #LoadError: cannot load such file – mysql
/Applications/SketchUp 2015/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require' /Applications/SketchUp 2015/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require’

:in `' SketchUp:1:in `eval'

In another topic I replied on how to [i]supposedly[/i] use pure ruby mySQL gems within SketchUp embedded Ruby.

I never tried loading the MySQL server on my computer, it seemed too big of a hassle. But I did get the support gems to load fine within SketchUp.

If you get it working let us know. I never got any feedback from the original poster in that topic thread.

Oh, and read that tutorial mentioned for how to use the DBI gem.

Thank you for your reply. I followed your words and installed all the gems. I can require ‘mysql’ and ‘dbi’ both from terminal and ruby files. However, I still cannot require neither ‘mysql’ nor ‘dbi’ from ruby console in Sketchup. I have no idea what is going on, the error info is the same as the previous one.

BTW, there is an old version sketchup8 on my friend windows PC, I just find that I could successfully require ‘mysql’ in ruby console and return ‘false’ with no error in that laptop, the plugin works fine in old version, but still cannot load it on the Sketchup2015 when I copy all the plugin files from the old version to the new one. I found the old version has the files, like ‘mysql.so’, ‘libmysql.dll’ in the plugin folder, and if I remove them, the plugin doesn’t work either.
I feel confuse about this problem because it stuck me for a while, I find some people asked similar question but there is no response works for my part.

The related gems list I installed:
mysql (2.9.1)
dbd-mysql (0.4.4)
dbi (0.4.5)
ruby (0.1.0)
ruby-mysql (2.9.13)
ruby-odbc (0.99997)
ruby-progressbar (1.7.5)
rubygems-bundler (1.4.4)
rubyzip (1.1.7, 1.1.6, 0.9.9)

I also installed ROR, and it also works fine.

are you installing the gems into SketchUp?

i.e. in ‘Ruby Console’
Gem.install(“mysql”)

or only on your system Ruby…

john

Oh, I only install the gems in my terminal. I think probably this is my point. However, when I type the Gem.install(“mysql”) in ruby console of Sketchup, it still shows some errors. Is there any document or reference I can follow for kind of problem? Thx.

Zhexiong

code below:
Gem.install(“mysql”)
Error: #<Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
“/Applications/SketchUp 2015/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.0/bin/ruby” extconf.rb
sh: /Applications/SketchUp 2015/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.0/bin/ruby: No such file or directory
Gem files will remain installed in /Users/szx/Library/Application Support/SketchUp 2015/SketchUp/Gems/gems/mysql-2.9.1 for inspection.
Results logged to /Users/szx/Library/Application Support/SketchUp 2015/SketchUp/Gems/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

That looks like you are trying to install the compiled version of the Gem instead of the pure ruby version. Please see the topic Dan linked earlier about this. SketchUp isn’t properly set up to build and install Gems that need to be compiled.

Yes, that’s my problem. just install the ruby-mysql gem in Sketchup, then it works. Thanks all you guys.

1 Like