ElektroStudios ElektroStudios - 7 months ago 32
Ruby Question

Can I hide the warning message "DL is deprecated, please use Fiddle" in Ruby?

The import instruction

require "Win32API"
throws this warning message at execution time:

DL is deprecated, please use Fiddle

It is very annonying to see that message every time that the script is ran, I'm just requiring
to launch a Win32 MessageBox, so really does not matter whether it is considered deprecated or not, it does not need a refactor at all for only one MessageBox.

Then, can I do something to hide that warning?


Edit <Ruby_Install_Dir>\lib\ruby\<VERSION>\Win32API.rb, delete the warn line in the file.

For my installation, the file locates in C:\Ruby23-x64\lib\ruby\2.3.0\Win32API.rb and the warning line is like

warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead" if $VERBOSE