# Another Rubyzip problem

**URL:** <https://forums.sketchup.com/t/another-rubyzip-problem/191449>\
**Category:** Ruby API\
**Tags:** zip, rubygems\
**Created:** [March 3, 2022, 7:35am UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449 "2022-03-03T07:35:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![brewsky](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/brewsky/32/5740_2.png) [@brewsky](https://forums.sketchup.com/u/brewsky)\
**Post date:** [March 3, 2022, 7:35am UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/1 "2022-03-03T07:35:32Z")

</div>

I recieved this error on my IFC Manager Extension:

> [@SketchUp IFC Manager extension](https://forums.sketchup.com/t/sketchup-ifc-manager-extension/147203/14):
>
> I am experiencing loading errors with the IFC Manager since version 4 through version 4.1.1. See attachment for Ruby Console information. The recently released version 3.6.0 doesn’t trigger this error, nor did the versions before that. [IFC manager error.txt](https://forums.sketchup.com/uploads/short-url/8oATmI7tOh6btQVUxpdLQVapaom.txt) (5.0 KB)

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](https://forums.sketchup.com/t/how-to-zip-files/58767/5)

The include happens [here](https://github.com/BIM-Tools/SketchUp-IFC-Manager/blob/6ebd07ce8426a76c49696de9a6f9a71bef641819/src/bt_ifcmanager/loader.rb#L60)  
I found out that older Sketchup versions need a specific version of rubyzip to work.

Anyone tips on this?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [March 3, 2022, 9:58am UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/2 "2022-03-03T09:58:12Z")

</div>

> [@brewsky](#):
>
> 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](https://forums.sketchup.com/t/how-to-zip-files/58767/5)

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](https://forums.sketchup.com/t/install-prawn-gem-in-sketchup-2016/76229/2)

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](https://rubocop-sketchup.readthedocs.io/en/latest/cops_requirements/#sketchuprequirementsgeminstall)

---

<div class="post-metadata">

**Author:** ![brewsky](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/brewsky/32/5740_2.png) [@brewsky](https://forums.sketchup.com/u/brewsky)\
**Post date:** [March 3, 2022, 10:19am UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/3 "2022-03-03T10:19:30Z")

</div>

> [@tt\_su](#):
>
> Embedding it into your own extension namespace is the way to go.

Thanks!

> [@tt\_su](#):
>
> Side note, if you use rubocop-sketchup to analyse your extension code you get a lot of recommendations and suggestions.

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

@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 😉 ). Do you think it worth the effort of applying for inclusion, or would it be rejected right away?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [March 3, 2022, 12:29pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/4 "2022-03-03T12:29:37Z")

</div>

> [@brewsky](#):
>
> @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 😉 ). Do you think it worth the effort of applying for inclusion, or would it be rejected right away?

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

---

<div class="post-metadata">

**Author:** ![brewsky](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/brewsky/32/5740_2.png) [@brewsky](https://forums.sketchup.com/u/brewsky)\
**Post date:** [March 3, 2022, 1:53pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/5 "2022-03-03T13:53:56Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![brewsky](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/brewsky/32/5740_2.png) [@brewsky](https://forums.sketchup.com/u/brewsky)\
**Post date:** [March 3, 2022, 3:02pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/6 "2022-03-03T15:02:16Z")

</div>

> [@tt\_su](#):
>
> What is the duplication? Is it a different UI to interact with the IFC schemas SU ships with?

 ![IFC manager UI](https://global.discourse-cdn.com/sketchup/original/3X/d/5/d55bf9b516387ad23fa29eeec9a5040009e002a9.jpeg)  
This is all the UI, it uses as much normal Sketchup features as possible.  
The rest is the IFC STEP serializer, all ruby…

> **[GitHub - BIM-Tools/SketchUp-IFC-Manager: IFC data manager and exporter for...](https://github.com/BIM-Tools/SketchUp-IFC-Manager)**
>
> IFC data manager and exporter for SketchUp. Contribute to BIM-Tools/SketchUp-IFC-Manager development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [March 3, 2022, 4:35pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/7 "2022-03-03T16:35:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [March 3, 2022, 10:33pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/8 "2022-03-03T22:33:43Z")

</div>

> [@brewsky](#):
>
> 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](https://forums.sketchup.com/t/how-to-zip-files/58767/5)

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:

- [Install Prawn gem in SketchUp 2016 - #2 by tt\_su](https://forums.sketchup.com/t/install-prawn-gem-in-sketchup-2016/76229/2)

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.

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [March 10, 2022, 2:13pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/9 "2022-03-10T14:13:20Z")

</div>

> [@brewsky](#):
>
> A little bit of UI but mainly a completely separate IFC serializer that uses the embedded XSD schema inside the Sketchup SKC’s

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

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [February 22, 2023, 1:08pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/10 "2023-02-22T13:08:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brewsky](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/brewsky/32/5740_2.png) [@brewsky](https://forums.sketchup.com/u/brewsky)\
**Post date:** [February 27, 2023, 9:36pm UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/11 "2023-02-27T21:36:52Z")

</div>

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

> <https://github.com/BIM-Tools/SketchUp-IFC-Manager/blob/master/src/bt_ifcmanager/lib/skc_reader.rb>

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [February 28, 2023, 12:21am UTC](https://forums.sketchup.com/t/another-rubyzip-problem/191449/12 "2023-02-28T00:21:59Z")

</div>

> [@brewsky](#):
>
> Hi @DanRathbun, that’s exactly what I did (on your advise 😄) no more gems in use…

👍

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

```ruby
    class SKC

      Zip ||= BimTools::Zip

      attr_reader :filepath, :name, :properties

      # ... etc. ...

```

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