Install Mysql gem

hello everyone,

i tried to install Mysql using the Sketchup Ruby Console :

Gem.install(“mysql”)

but it gave me an install error, any help plz ?

this the errors message.

Gem.install(“mysql”)
Error: #<Gem::InstallError: The ‘mysql’ native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from ‘Downloads’ and follow the instructions
at ‘Development Kit · oneclick/rubyinstaller Wiki · GitHub

C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:12:in rescue in block in <top (required)>' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/defaults/operating_system.rb:4:in block in <top (required)>’
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:244:in call' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:244:in block in run_pre_install_hooks’
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:243:in each' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:243:in run_pre_install_hooks’
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/installer.rb:209:in install' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:372:in block in install’
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in each' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in each_with_index’
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:332:in install' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems.rb:526:in install’

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

MaryamR

This is a source gem, that needs the Ruby DevKit installed on the end user system, because it needs to be compiled at install time. But, SketchUp embedded Ruby is not yet set up to be hooked into the Ruby DevKit. So, gems that need compiling are a problem for SketchUp.

Choices, are:

(A) to install both the 32-bit and 64-bit Ruby DevKits and pre-compile the gem for each platform and bitness, and distribute them with your plugin code, using a conditional expression to choose the correct (platform and bitnees) compiled library to load into SketchUp’s embedded Ruby.

(B) find already pre-compiled binaries of the library, and package them with your plugin.

(C) find alternate pure-ruby library gem(s) that do not need compiling, and therefor are already cross-platform.


I have been recommending (C), the Pure-Ruby gems that need no compiling.
See:
Pure Ruby replacement libraries for the “mysql” gem

2 Likes

thank you for your answer,
Is there a Mysql gem that is pure Ruby ? and how can i install it using the Sketchup Ruby Console ?

hello ,

I have Ruby 2.0.3
i tried to install Mysql-ruby from the Sketchup ruby console using : Gem.install(“mysql-ruby”)
but it gave me this error.
Gem.install(“ruby-mysql”)
Error: #<Gem::SpecificGemNotFoundException: Could not find a valid gem ‘ruby-mysql’ (>= 0) locally or in a repository>
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:301:in find_spec_by_name_and_version' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:110:in available_set_for’
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/dependency_installer.rb:322:in install' C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems.rb:526:in install’

but SU doesn’t, it has a slightly modified version of RUBY_VERSION 2.0.0

any gem needs to be compatible with that base version…

john

1 Like

When i opened the rubygems.reb file in the Sketchup Tools\RubyStdLib folder i found this line:

module Gem
VERSION = ‘2.0.3’
end

but the mysql-ruby gem is 2.9.14 version according to : ruby-mysql | RubyGems.org | your community gem host
So how can i install mysql in Sketchup Ruby Console

This is the version of the RubyGems extension, not the Ruby build itself. (Notice how it is wrapped within the Gem namespace module ?)

The version of Ruby is set to the global constant RUBY_VERSION, example:

  puts "The version of Ruby is: "<<RUBY_VERSION

Yes, the gem’s latest version is 2.9.14

You keep writing “mysql-ruby”,… the correct identifier for the gem is: "ruby-mysql"

We cannot see the error output. You need to wrap error output in a preformatted textblock (use the “</>” button on the posting edit toolbar,) or wrap the whole block of error text in a block like:

```
Gem.install("ruby-mysql")
Error: #<GemInstallError: could not read respository for "ruby-mysql">
the rest of the error text and backtraces, etc., …
```

A multiline preformatted textblock begins with three 3 backticks (```) on a line by themselves, and ends with three 3 backticks (```) on a line by themselves.

1 Like

BTW,… I got no errors, and the gem specification was created under both SketchUp 2015 and SketchUp 2016:

Gem.install("ruby-mysql")

>>
[#<Gem::Specification:0x8b2a3d8 ruby-mysql-2.9.14>]

1 Like