Win32API is deprecated after Ruby 1.9.1
-
I'm getting this error
@unknownuser said:C:/Program Files/SketchUp/SketchUp 2021/Tools/extensions.rb:197: warning: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead
My plugin was working before today and I haven't changed anything, what can be causing this error all of a sudden?
Thanks
-
Thanks for the info Dan... I didn't check to see if there's a difference when loading different versions, just haven't had time and other than being annoying I don't see any problems in my plugin.
When I get a chance I'll look into it more and see if there are other errors as you suggested.
-
@dan rathbun said:
The warning cannot be suppressed as it is stated at the top of the "
Win32API.rb
" wrapper file without condition.Actually (today) I myself decided to modify the "Win32API.rb" file in the Ruby library, and comment out that warning at the top of the file.
To do this I had to start Notepad++ in Administrative mode because SketchUp has marked it's "Tools" folder files and all subfolder files as read only.
@frankn said:
I didn't check to see if there's a difference when loading different versions, just haven't had time and other than being annoying I don't see any problems in my plugin.
I do not think that the "Win32API.rb" file has changed at all. If you do not see any issues, then likely there are none.
The main takeaway here is that the "Win32API.rb" wrapper file is deprecated. This means such things could be (and are likely scheduled to be) removed in a future Ruby version. This would most likely happen in a major version release such as 3.0 which is now the stable active trunk.
The current release is 3.0.2 and I've just now installed it and checked for the "Win32API.rb" wrapper file. It has been REMOVED from the Ruby standard library.
So this means that coders will need to edit their code and either, use
Fiddle
calls directly, or copy the contents of the "Win32API.rb" file (minus the warning) into their own namespace module as a local class definition. -
This is not an error. It is a warning.
Prior to Ruby 2.x,
Win32API
was a compiled.so
file.Then they (the Ruby Core project) deprecated it and began (with Ruby 2.0 in SketchUp 2014 thru 2016) distributing Ruby with a "
Win32API.rb
" wrapper file that defined wrapper calls using theDL
standard library.But later on (by Ruby 2.2.4 with SketchUp 2017 and higher,) even the
DL
standard library was deprecated, and the "Win32API.rb
" wrapper file was rewritten to change theDL
library calls intoFiddle
library calls.So even now with Ruby on the latest SketchUp, we would still expect old
Win32API
method calls to be translated correctly intoFiddle
library calls.The warning cannot be suppressed as it is stated at the top of the "
Win32API.rb
" wrapper file without condition. You will see it output to the console by the first extension that calls arequire "Win32API"
.
Okay, but there is always a chance things could have been broken as changes to the
Fiddle
library might change with Ruby version changes.The latest SketchUp 2021 is now up to Ruby version 2.7.2. SketchUp 2020 was using Ruby version 2.5.5.
Did you see differences between loading under these 2 Ruby versions ?
I would suggest using a Ruby Console opener like Eneroth's to see what other errors are output to the console. It is best when troubleshooting to switch off the extension so it does not load at startup, and then manually load it with the console open to see any other errors.
Advertisement