Another Rubyzip problem

I recieved this error on my IFC Manager Extension:

It has to do with the rubyzip gem I included since version 4 (to be able to extract the XSD schema from the SKC’s and export ifcZIP files).

I could directly include the rubyzip code in my own namespace, but using a gem seemed like the official way to do this. Like @DanRathbun mentioned here

The include happens here
I found out that older Sketchup versions need a specific version of rubyzip to work.

Anyone tips on this?

That is not correct - SketchUp do not support the gem system. We strongly recommend against using it in production extensions. Embedding it into your own extension namespace is the way to go.

More details: Install Prawn gem in SketchUp 2016 - #2 by tt_su

There seem to be more and more questions about usage of gems. I’m almost tempted to introduce a warning to SU’s version of Gem.install to make it clear that it’s not a supported or recommended feature.

Side note, if you use rubocop-sketchup to analyse your extension code you get a lot of recommendations and suggestions. It also cover a number of cases where we might reject an extension to the Extension Warehouse. Gem.install is one of these: Requirements Cops - RuboCop SketchUp: SketchUp Extension Best Practices

2 Likes

Thanks!

And thanks again! I will take another serious look into that :smiley:

@tt_su A related side question. I never applied for inclusion of this addon in the extension warehouse because it is a partial duplicate of core functionality.
I hope it’s an improvement over te native IFC export (that’s the idea behind it anyway :wink: ). Do you think it worth the effort of applying for inclusion, or would it be rejected right away?

1 Like

What is the duplication? Is it a different UI to interact with the IFC schemas SU ships with?

@tt_su A little bit of UI but mainly a completely separate IFC serializer that uses the embedded XSD schema inside the Sketchup SKC’s


This is all the UI, it uses as much normal Sketchup features as possible.
The rest is the IFC STEP serializer, all ruby…

I see many complaints in the Ruby Console about redefined constants because the Rubyzip Gem code is embedded within more than one extension - each of its constants triggers a warning when the code is loaded again by each extension. Unless modules are renamed in each such use, such (harmless but annoying) collisions seem inevitable.

For the record, that was an old post. Use of RubyGems (especially binary gems) has gotten progressively more complicated and problematic over the years.

So what used to work easily, does not anymore as Thomas explained in his linked post:

Around SU v2018 RubyGems core changed and it’s web repository stopped working with older versions that SketchUp still had.


Re RubyZip, I believe is all pure Ruby. No binaries.

It has what it lists as minimum required Ruby version, but I think this may just be the “supported” minimum version. Ie, the author does not support installing the gem into old Ruby version that are at end of life.

1 Like

Send us an email on developer-support@sketchup.com about this. Then I can pull in the required people to weigh in.

So, just to follow up on the RubyZip challenge, your extension can wrap it within your namespace as a library, and then your IFC serializer class (or module) can use include to bring in the Zip module. This then will not collide with any other extension.

Hi @DanRathbun, that’s exactly what I did (on your advise :smile:) no more gems in use…

:+1:

FYI, use can always assign a local constant to point to another object.
Modules are objects. (Ie, everything in Ruby is an object.)

    class SKC

      Zip ||= BimTools::Zip

      attr_reader :filepath, :name, :properties

      # ... etc. ...

… then you can use it like it’s documentation gives the examples.