Problem while using find method of Find Module in Ruby 1.9.2

1.2k Views Asked by At

I am writing the following code in irb in my windows terminal having ruby-1.9.2... and even though the code is just using the find function of the module Find, I am encountering the following error:

irb(main):001:0> require 'find'
=> true
irb(main):002:0> Find.find("") do |f|
irb(main):003:1* p f.to_s
irb(main):004:1> end
Errno::ENOENT: No such file or directory
        from C:/Ruby192/lib/ruby/1.9.1/find.rb:38:in `block in find'
        from C:/Ruby192/lib/ruby/1.9.1/find.rb:38:in `collect!'
        from C:/Ruby192/lib/ruby/1.9.1/find.rb:38:in `find'
        from (irb):2
        from C:/Ruby192/bin/irb:12:in `<main>'

I have also tried the above code in a file(.rb) but am encountering the same error.

Thanks in advance...

1

There are 1 best solutions below

3
On BEST ANSWER

You're passing an empty string to the .find method. You're supposed to pass the paths you want to traverse as an argument, for example Find.find("/tmp") do |f|.

See the Find module's documentation for an example.