Cannot Sketchup.require .so?

I have a file. It is working with require as below:

require 'google/protobuf_c'

Now, I need to encrypt my plugin. So to change the require to Sketchup.require:

Sketchup.require 'google/protobuf_c'

But I get the error:

Could not find included file 'google/protobuf_c'

How can I fix it?

:thinking: Perhaps check this:
Sketchup.require failing in local gem after encryption - Developers / Ruby API - SketchUp Community

It should load Ruby C Extensions, yes. Hard to say what is going on without a complete example to test.

Though, you only need to use Sketchup.require when referring to .rb files, since they are the only files being replaced during encryption.

Sketchup::require does not search for so files. The documentation states:

This method will look for .rbe first (encrypted) and then .rbs (the deprecated scrambled format) and finally .rb (unencrypted) files.

So have your code use the global require method for loading .so / .dll / .dylib library files.


Thanks. Yes, I need to use require for .so files instead of Sketchup.require.

Because I do not want to encrypt the google/protobuf lib again, so removing it entirely before encrypting. Then encrypt it to get .rbz to download. Next, unzip the .rbz, restore the google/protobuf. Finally zip all into a .rbz again. The process works, though it is tedious. Especially some mistakes occur when installing the plugin, I have to repeat the whole process again and again.

I would suggest just letting the gem’s rb files be encrypted.

1 Like

I would suggest looking into Rake to automate tasks like these. I use the same workflow you describe for my plugin. You can simply pause the Rake task with something like STDIN.gets.chomp, encrypt and sign the archive, replace it with the encrypted one and then proceed with the task.

You could also automate the signing, but this stopped working for me recently.

1 Like

I checked my own extensions, that’s what I do as well, I use require for C Extensions, but SketchUp.require for .rb files. Once you have the requires right you should be good to go.

1 Like

Thank you very much @Rojj. I will try it out because we need to encrypt frequently our plugin recently.