SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

Gem is not Working in SketchUp 2021 but working in SketchUp 2020 (Win 10) #709

Closed J-E-L closed 2 years ago

J-E-L commented 2 years ago
  1. SketchUp 21.1.332 64-bit
  2. OS Platform: Windows 10

I use tiny_tds for connecting SketchUp (ruby) with a Microsoft SQL Server.

With SketchUp Version 20.2.172 64-Bit on Windows 10 I can do following commands.

Gem.install 'tiny_tds'

require 'tiny_tds'

TinyTds::VERSION

Version is 2.1.5

With SketchUp Version 21.1.332 64-Bit on Windows 10 I can do flowing commands.

Gem.install 'tiny_tds'

I get the following Errors! and can not connect to a Microsoft SQL Server. Is the Problem that you are Compiling ruby yourself?

C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:80:in rescue in run' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:79:inrun' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/ext_conf_builder.rb:48:in block in build' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/tempfile.rb:291:inopen' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/ext_conf_builder.rb:30:in build' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:169:inblock in build_extension' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:165:in synchronize' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:165:inbuild_extension' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:210:in block in build_extensions' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:207:ineach' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:207:in build_extensions' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/installer.rb:844:inbuild_extensions' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/installer.rb:327:in install' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/resolver/specification.rb:93:ininstall' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/request_set.rb:195:in block in install' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/request_set.rb:183:ineach' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/request_set.rb:183:in install' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/dependency_installer.rb:325:ininstall' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems.rb:633:in `install'

J-E-L commented 2 years ago

This problem could have several other ruby ​​gems. SketchUp 2020 RUBY_VERSION = 2.5.5 RUBY_PLATFORM = x64-mingw32

SketchUp 2020 RUBY_VERSION = 2.7.2 RUBY_PLATFORM = x64-mswin64_140

DanRathbun commented 2 years ago

Is "tiny_tds" a pure Ruby gem, or a binary gem that needs compiling ?

FYI, you cannot compile binary gems inside SketchUp. You need to do it in system Ruby installs outside SketchUp, and then use the compiled .so files in your extension.

Or find pre-compiled gem packages and use those.

But note that if you are supporting multiple SketchUp versions, your extension will need to "sniff" SketchUp's Ruby version and load the correct compiled binary for that version. (You may also need to compile editions for Mac if supporting that platform.)

Lastly, beware of gems that modify the core Ruby classes. They might cause problems for other extensions. (Generally, Ruby Gems are not written to be used in a shared Ruby process where multiple extensions are running as in SketchUp.)

J-E-L commented 2 years ago

"tiny_tds" need compiled binary. For Windows RUBY_PLATFORM = x64-mingw32 there are included compiled ".so" extensions. The extension is working well under SketchUp 2020!

SketchUp 2021 is compiled with RUBY_PLATFORM = x64-mswin64_140 and the extension need to be compiled for "RUBY_PLATFORM = x64-mswin64_140" which is not working in SketchUp.

https://github.com/rails-sqlserver/tiny_tds

Now I only can use SketchUp 2020 to connect to Microsoft SQL Server easily.

DanRathbun commented 2 years ago

You may find some information of benefit here:

https://github.com/SketchUp/ruby-c-extension-examples#readme

J-E-L commented 2 years ago

Thanks for the information about compiling. However, I would like to show that SketchUp 2021 has worsened compared to 2020 for the use of ruby ​​extensions with c-dll. It makes a big difference whether I use the "Gem.install" command or whether I have to recompile the ruby c-dll. Furthermore, I can't easily use the ruby ​​makefiles because they are written for "RUBY_PLATFORM = x64-mingw32" and SketchUp from version 2021 uses "RUBY_PLATFORM = x64-mswin64_140". This problem may exist with many other ruby ​​gems with precompiled c-dll And I was hoping someone had a simple solution to this problem. My solution is to use SketchUp 2020 to communicate with Microsoft SQL Server. (tiny_tds)

thomthom commented 2 years ago

We don't support the Gem system within SketchUp due to the problems with compiled gems. Another problem is that different extensions relying on different versions of a gem would be a problem.

In general we recommend that if an extension needs a gem that they make a copy of it and put it under their extension namespace to isolate it. This does mean one would need to figure out how to build it yourself.

As Dan suggested, building your own Ruby C Extension (not gem) that uses a C or C++ library might be a more sustainable approach.