"Invalid extension file structure" when attempting to publish?

I’m getting this error when trying to submit my extension for publishing.

I’ve tried following the recommended best practices here… I’m uploading a renamed .zip file which uses the following structure:

texture_club.zip (or .rbz)
- texture_club.rb
- texture_club/
  - main.rb

The contents of texture_club.rb are super simple, it just loads main.rb as recommended.

require 'sketchup'
require 'extensions'

# Wrapper module for the extension.
module TextureClub
  unless file_loaded?(__FILE__)
    ex = SketchupExtension.new('Texture Club', 'texture_club/main')
    ex.description = 'Install materials into your model directly from vendor websites.'
    ex.version = '0.0.0'
    ex.copyright = 'https://texture.club'
    ex.creator = 'https://texture.club'
    Sketchup.register_extension(ex, true)
    file_loaded(__FILE__)
  end
end

Screenshot of the error that I’m seeing.

(A) Your file structure looks okay to me.


(B) I would suggest the registrar file be more like this:

# encoding: UTF-8
# 
# SketchUp extension registrar file: texture_club.rb

require 'sketchup' unless defined?(LanguageHandler)
require 'extensions' unless defined?(SketchupExtension)

# Wrapper module for the extension.
module TextureClub

  EXTENSION ||= SketchupExtension.new('Texture Club', 'texture_club/main')

  EXTENSION.instance_eval do
    self.description = 'Install materials into your model directly from vendor websites.'
    self.version   = '0.0.0'
    self.copyright = 'https://texture.club'
    self.creator   = 'https://texture.club'
  end

  unless Sketchup.extensions.include?(EXTENSION)
    Sketchup.register_extension(EXTENSION, true)
  end

end

Meaning that a lot of us do not recommend using the global API methods file_loaded() and file_loaded? as string comparison is slow. It also is not really necessary for registrar files in the “Plugins” folder as SketchUp only processes this folder once during the startup cycle.

The better tests to avoid duplication are the ||= operator to ensure only one SketchupExtension object is instantiated and testing the members of the SketchupExtensionsManager collection whether your extension object has already been registered.


(C) Most often an extension author or company with define a unique top-level namespace module, then a submodule inside this for each one of their extensions.

  • I do not know if this would trigger the “invalid file structure” error.

As given in the best practices the convention is to name the register file and extension folder the same as (or as close similar to) the module nesting of the code.

Example:

registrar file: "textureclub_importer.rb"
extension folder: "textureclub_importer"

module TextureClub
  module Importer

  EXTENSION ||= SketchupExtension.new('Texture Club', 'textureclub_importer/main')

Trimble tends to downcase the names of the extension files and folders (as shown above.)
I myself only downcase the names of the files within the extension subfolder. (I like the camelcase of the registrar file and subfolder to match the Ruby module indentifiers, like: "TextureClub_Importer.rb")

Thanks for the reply! I’ll give the sub module a shot and try again.

Hmmm got around to making your suggested changes, no luck. I’ll try creating a support ticket.

Just to follow up in case anyone else runs into this. I was able to get past the error that I was experiencing by switching to linux and recreating the rbz file.

Previously was using an npm package (cross-zip) on Windows.

There is no need to use a 3rd party app on Windows. Creating Zip archives is built-in.
But you do need to rename the filetype from “.zip” to “.rbz” afterward.

P.S. : I actually also have 7-Zip installed for opening and extracting from Zip archives. Works well, but the built-in “Send to > Compressed (zipped) folder” is so quick I never use 7-Zip for making my RBZ archives.

Yeah I know. I was only using the library so I that I could build windows/linux w/ the same command. Ideally I’d have CI create these releases for me in the future.

1 Like