Win32API is deprecated after Ruby 1.9.1

Win32API is deprecated after Ruby 1.9.1

Postby Frankn » Mon Mar 22, 2021 5:18 pm

I'm getting this error
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
0

Frankn 
 

Re: Win32API is deprecated after Ruby 1.9.1

Postby Dan Rathbun » Fri Apr 23, 2021 6:10 pm

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 the DL 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 the DL library calls into Fiddle library calls.

So even now with Ruby on the latest SketchUp, we would still expect old Win32API method calls to be translated correctly into Fiddle 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 a require "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.
0
Last edited by Dan Rathbun on Fri Aug 06, 2021 4:22 am, edited 1 time in total.
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: Win32API is deprecated after Ruby 1.9.1

    Postby Frankn » Mon May 10, 2021 1:25 am

    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.
    0

    Frankn 
     

    Re: Win32API is deprecated after Ruby 1.9.1

    Postby Dan Rathbun » Wed Jul 14, 2021 8:15 pm

    Dan Rathbun wrote: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 wrote: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.
    0
      I'm not here much anymore. But a PM will fire email notifications.
      User avatar
      Dan Rathbun 
      PluginStore Author
      PluginStore Author
       

      SketchUcation One-Liner Adverts

      by Ad Machine » 5 minutes ago



      Ad Machine 
      Robot
       



       

      Return to Developers' Forum

      Who is online

      Users browsing this forum: No registered users and 10 guests