• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Win32API is deprecated after Ruby 1.9.1

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 2 Posters 8.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    Frankn
    last edited by 22 Mar 2021, 16:18

    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

    1 Reply Last reply Reply Quote 0
    • F Offline
      Frankn
      last edited by 10 May 2021, 00:25

      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.

      1 Reply Last reply Reply Quote 0
      • D Offline
        Dan Rathbun
        last edited by 14 Jul 2021, 19:15

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

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 6 Aug 2021, 03:22

          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.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement