Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top