Ruby 2.0.0p0 IRB warning: "DL is deprecated, please use Fiddle" - ruby

I just uninstalled my older versions of Ruby, removed all of my gems
(including Rails), and installed Ruby 2.0. In other words, a totally clean re-install. Upon starting IRB, I received this message:
DL is deprecated, please use Fiddle
Note: I'm on a Windows machine.
What does this message mean?

The message you received is common when you have ruby 2.0.0p0 (2013-02-24) on top of Windows.
The message "DL is deprecated, please use Fiddle" is not an error; it's only a warning.
The source is the Deprecation notice for DL introduced some time ago in dl.rb ( see revisions/37910 ).
On Windows the lib/ruby/site_ruby/2.0.0/readline.rb file still requires dl.rb so the warning message comes out when you require 'irb' ( because irb requires 'readline' ) or when anything else wants to require 'readline'.
You can open readline.rb with your favorite text editor and look up the code ( near line 4369 ):
if RUBY_VERSION < '1.9.1'
require 'Win32API'
else
require 'dl'
class Win32API
DLL = {}
We can always hope for an improvement to work out this deprecation in future releases of Ruby.
EDIT:
For those wanting to go deeper about Fiddle vs DL, let it be said that their purpose is to dynamically link external libraries with Ruby; you can read on the ruby-doc website about DL or Fiddle.

You may want to comment out the DL is deprecated, please use Fiddle warning at
C:\Ruby200\lib\ruby\2.0.0\dl.rb
since it’s annoying and you are not the irb/pry or some other gems code owner

I got this resolution at openshift.com.
Resolution:
This error occurs only on Windows machine with Ruby 2.0.0 version.
Until we officially support Ruby 2.0 please downgrade to Ruby 1.9.
On Windows, you can install Ruby 1.9.3 alongside 2.0. Change your
%PATH% to c:\ruby193\ or whatever directory you installed to prior
to installing the gem.

The message "DL is deprecated, please use Fiddle" is not an error; it's only a warning.
Solution:
You can ignore this in 3 simple steps.
Step 1. Goto C:\RailsInstaller\Ruby2.1.0\lib\ruby\2.1.0
Step 2. Then find dl.rb and open the file with any online editors like Aptana,sublime text etc
Step 3. Comment the line 8 with '#' ie # warn "DL is deprecated, please use Fiddle" .
That's it, Thank you.

I ran into this myself when I wanted to make a thor command under Windows.
To avoid having that message output everytime I ran my thor application I temporarily muted warnings while loading thor:
begin
original_verbose = $VERBOSE
$VERBOSE = nil
require "thor"
ensure
$VERBOSE = original_verbose
end
That saved me from having to edit third party source files.

Related

DL is deprecated, please use Fiddle

I just installed a ruby 2.2.1 and got this warning when I ran bundle install:
DL is deprecated, please use Fiddle
I came to this question and found the code they pointed out in rbreadline.rb line 4367.
if RUBY_VERSION < '1.9.1'
require 'Win32API'
else
require 'dl'
class Win32API
DLL = {}
TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
I then added the require 'irb' line next to the require 'dl' line as they suggested but this did not remove the warning for me. I realize this may only be a warning but I do not want to comment out the message only to have other problems spring up latter. How do I fix this?
There was a broken version of RubyInstaller that was distributed for about 5 hours.
There were only about 800 downloads of it before someone caught it, but it appears that you are running one of those downloads.
Sorry about that.
Check out the mailing list announcement for more details.
The fix is to re-install using the fixed distribution.

Is there a trick to profiling memory usage w/ ruby-prof using an rvm gemset?

I've been trying to get ruby-prof working for memory usage on Mac OS X w/ Ruby 1.8.7 and so far I'm not having much luck.
I understand from the documentation that RubyProf::MEMORY mode requires a patched version of Ruby. I've tried installing the GC-patched version (which I found referenced in the Rails documentation) through RVM:
rvm reinstall 1.8.7 --patch ruby187gc
Based on the output of this command, everything looks good. I clearly see "Applying patch 'ruby187gc'" in the console output.
The problem seems to come when trying to use an RVM gemset. I wrote the following script to test this:
require "ruby-prof"
RubyProf.measure_mode = RubyProf::MEMORY
results = RubyProf.profile do
# code to measure
end
File.open(File.join(File.dirname(__FILE__), "profile-graph.html"), "w") do |file|
RubyProf::GraphHtmlPrinter.new(results).print(file)
end
When I preceed this script with rvm use 1.8.7 --patch ruby187gc, it creates the file "profile-graph.html" showing memory usage of all the different method calls in the script, as I'd expect. However, when I try something like rvm use 1.8.7#gemset_name --patch ruby187gc, the output file contains all "nan" values.
What gives? Is there some special trick to using a patched version of Ruby along with an RVM gemset? Does the problem lie elsewhere? I'm crossing my fingers and hoping that someone has run into a very similar problem and figured this out before.
Ah, I was overcomplicating things. Turns out I just needed to uninstall and reinstall the ruby-prof gem (after patching Ruby).

Use RbConfig instead of obsolete and deprecated Config

While trying to install ImageMagick on Windows through msys.bat by running
ruby setup.rb install
I'm getting this error:
setup.rb:787: use rbconfig instead of obsolete and deprecated config.
no such file or directory -.config
setup.rb config first
Try ruby setup.rb --help for detailed usage
RbConfig is a Module which gives access to mostly compile time properties of the current Ruby implementation. To use RbConfig one has to require 'rbconfig'. In earlier versions of Ruby this class was just called Config and was loaded through require 'config'. When trying to use Config nowadays, Ruby will give out a deprecation warning.
Go into your setup.rb into line 787. There you will probably find a require 'config'. Change that into a require 'rbconfig'. If that doesn't make the script run or there are still warnings, search and replace usages of the Config module with RbConfig. Then Ruby will shut up.
The problem probably only appears the software you are trying to compile is not up to date. I guess an even better way to make it work would be to find a more current version of it, which may solve additional problems.
Had same problem solved it through:
#aef's answer and ther changing the file to look like below:
require 'tempfile'
if i = ARGV.index(/\A--rbconfig=/) then
file = $'
ARGV.delete_at(i)
require file
require 'rbconfig'
else
require 'rbconfig'
end

Problem with Vim's Ruby plugin

I have just installed Vim and when ever I go to open in ruby file I get these errors:
Error detected while processing C:\Program files (x86)\Vim\vimfiles\ftplugin\ruby.vim
line: 76
Encoding::ConverterNotFoundError: code converter not found (UTF-16LE to ASCII-8bit)
line: 93
E121 :Undefined varaible: s:ruby_path
E15: Invalid expression: s:ruby_path
line: 76
NameError: uninitialized constant Gem::Quickloader
line: 93
I have Ruby 192 installed and I get this error even if I update ruby vim files.
These are the two lines those errors are referring to if it helps:
line 76: ruby VIM::command( 'let s:ruby_path = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
line 93: let &l:path = s:ruby_path
Note that instead of editing ruby.vim file you can just add
let g:ruby_path = ':C:\ruby192\bin'
in your _vimrc file (or equivalent for your platform). That way you won't need to keep re-editing ruby.vim when you update it.
If you run RVM and want its default ruby, use:
let g:ruby_path = "/Users/allen/.rvm/rubies/default/bin"
If you set your ruby interpreter in your project .rvmrc file, you can create an environment variable in your .rvmrc:
rvm 1.9.2#projectname --create
export RUBY_BIN=`which ruby | sed 's/ruby$//'`
You can use environment variables in your .vimrc:
let g:ruby_path=$RUBY_BIN
(Note you should also set a default $RUBY_BIN in your .bashrc or .zshrc so this works outside of .rvmrc projects.)
If your ~/.rvm/rubies/default/bin path does not yet exist, you need to set your rvm system default of ruby. At your command prompt or terminal application, enter:
rvm use 1.9.2 --default
using whatever ruby version you need.
How did you install Ruby?
Go into irb and enter:
Gem.all_load_paths.uniq
which should return a list of paths to your install gems that Gem knows about also.
That's what is failing in your error message and leads me to suspect you are missing some path or environment info, because it looks like vim isn't able to find your Ruby gems correctly.
Encoding::ConverterNotFoundError is a core library exception, so that part is working, but it looks like the Gem command isn't working.
Your problem is probably Ruby 1.9 - AFAIK Vim only works with Ruby 1.8, so you might have to downgrade your Ruby version to get Vim working.
I opened the file "C:...\vim73\ftplugin\ruby.vim" and right before line 73 or so, where the code reads:
if !exists("s:ruby_path")
I added:
let s:ruby_path = 'C:\ruby192\bin'
So far vim seems happier about editing ruby files. Note I installed my ruby in the "C:" directory instead of "Program Files" to get a better pathname to ruby.exe.
My version of ruby.vim is dated 2010 Mar 15.
Updating to the latest release of Ruby 1.9.2 (1.9.2p180 (2011-02-18) at the time of posting) fixed this for me.
I was running 1.9.2p132 or so when I had the problem, which seems to have been patched around Dec 2010. You can check your current version by running ruby -v.

Why does my Sproutcore development server drop connections with "invalid byte sequence in US-ASCII"?

Here's the stack: Sproutcore 1.0.1046. Ruby 1.9.1, in RVM. Thin 1.2.7. Thor 0.13.8. Rack 1.2.1. Eventmachine 0.12.10. Erubis 2.6.6.
When I start the sc-server on any application, my first request to this server produces this in the console log:
ArgumentError: invalid byte sequence in US-ASCII
...followed by this stack trace. (I've listed gems which appear in the stack trace above, but there's a complete gemset list in the same gist as the stack trace.)
Research on the error message points out that this is a common problem with Ruby 1.9, but the stack trace suggests that the problem is in one of the gems somewhere.
I have:
Upgraded my OS (Mac OS X 10.5 to 10.6) in order to get the latest gcc Apple provides.
Reinstalled RVM.
Reinstalled Ruby.
Reinstalled all the relevant gems.
And yet I still have this problem on one system, but not on another. (N.B. there are several devs working on this code, and I'm the only one seeing this problem. I'm 99% certain it's not our code.) I guess what I'm saying is that I've cleared and rebuilt a lot of gems to try to isolate or remove this glitch, and yet I still haven't gotten rid of it.
Where should I look next?
You have some special setting in your bash environment that is setting ruby to use US-ASCII , this happened to me trying to execute sc-server from a remote terminal... I'm not really sure what it is, but it doesn't use UTF-8 and that's when it runs into trouble.
You can probably also change Encoding.default_external
Thanks so much for the Encoding.default_external suggestion. I was having the same problem, despite correctly set magic comments and environment variables. In Rails 2.3.9 I added this before_filter in application_controller.rb, resolved the issue:
def set_encoding
Encoding.default_external = 'UTF-8'
end
I had the same issue with RSS Feeds that I was displaying in a Rails 2.3.8 app with Ruby 1.9.2. My issue wasn't solved by the application_controller.rb before_filter technique mentioned here. The fix was to put the following into "RAILS_ROOT/config/initializers/string_encodings.rb":
Encoding.default_external = 'UTF-8'
That worked for me site-wide, instead of on a controller level.
In my case the ArgumentError occurred during a Capistrano deploy call that envolves ruby's net-ssh (ruby 1.9.2p290, net-ssh 2.3.0). None of the solutions afore mentioned worked and none of the other reasons I've read about so far: i.e. "strange character in key file", etc..
Finally, I found a none ASCII-character in a comment(!) line in my ASCII encoded ~/.ssh/config file. BINGO!

Resources