Problem with Rubyzip and Windows user name with special characters

Here’s the error code:

rror: #<LoadError: cannot load such file -- zip>
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:92:in `require'
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:92:in `require'
c:/wps/wps - sketchup/wps library/system/wps_update_system.rbs:9:in `<main>'
c:/users/usuário/appdata/roaming/sketchup/sketchup 2021/sketchup/plugins/wps_plugin.rbs:9:in `eval'
c:/users/usuário/appdata/roaming/sketchup/sketchup 2021/sketchup/plugins/wps_plugin.rbs:9:in `require'
c:/users/usuário/appdata/roaming/sketchup/sketchup 2021/sketchup/plugins/wps_plugin.rbs:9:in `<main>'
SketchUp:in `eval'
Error: #<NameError: uninitialized constant WpsUpdateSystem>
c:/users/usuário/appdata/roaming/sketchup/sketchup 2021/sketchup/plugins/wps_plugin.rbs:10:in `<main>'
SketchUp:in `eval'

When the username doesn’t have special characters such as “Usuario” the plugins start normally but if it does have “Usuário”, in the return of the appdata query it can’t read.

Change the name in the windows registry until it resolves but breaks other programs.

All files where require ‘zip’ exist, return error.

How can I fix it? Thanks a Lot.

Check out this article
My thought is to change the user name is the easiest way to solve the situation.

The paths etc
c:/users/usuário/appdata/roaming/sketchup/sketchup 2021/sketchup/plugins/wps_plugin.rbs
What is its encoding ?

Can you try and force its encoding the ‘UTF-8’, before using it ?

There’s lots written about what you can and can’t do with a Windows user-name - I think having any accented letters etc is a bad idea…

What does your require look like? Have you bundled the rubyzip gem with your extension, or have you installed it as a gem?

Hello, the rubyzip gem was installed using the console,
I solved the problem by removing the gem from appdata and placing it in Sketchup’s tools folder. Thanks

@Solos,

I know this is rather old, but I’ve got a question. What does the following return:

Dir.exist? Gem.path.first

I think that the old RubyZip gem used require "zip" … but this was later changed to require "rubyzip" in later versions of the gem.

This is not the solution.

In later SketchUp versions there is a hash file for the “Tools” folder.
If anything is added, or files changed in this folder, SketchUp will not load them.

Stay out of the %ProgramFiles% application path.

It would be better if you installed the Zip library into the %ProgramData% path’s "Plugins" folder.

Generally, the SketchUp Extensibility Team advises to wrap pure Ruby gems inside your extension submodule or your top level namespace module.


@MSP_Greg This may be a regression of an old issue with older SketchUp versions running on Windows, where it did not support Unicode characters in file paths so require would fail. This also means the SketchUp’s GEMHOME and GEMPATH might also fail because they are also in the user’s %AppData% path. (I would have thought that this was fixed by the time SU2021 shipped.)

Another ugly problem happens because somehow in the code the forward slashes are changed to backslashes without escaping and the path then contains "\u" for the first character in the ("usuário") username, which gets interpreted as the beginning of a Unicode character sequence, but is not correct so causes an error.
For example, the Dynamic Components extension code had this internal coding error (and might still have it.)

@DanRathbun

I hate encoding issues. They may be caused by:

  1. Ruby
  2. RubyGems
  3. SketchUp

I think my previous WIndows desktop I had a directory with unicode ‘letters’, some of the characters were European, others were Asian. I think I was using it for Ruby testing, as opposed to SketchUp testing, but I don’t recall. I copied the directory to my current desktop, but I don’t think I’ve used it for any testing. Not.Sure. I may have also created a user account with similar characters on the old system.

I’ll see if I can dig around…

It does still have that problem, and it’s in string handling routines. I wouldn’t be surprised if other parts of SketchUp also had problems with paths that include /u.

1 Like