Search code examples
rubywindowsglobdirruby-2.1

Ruby Dir.glob issue only on Windows


This line:

dirs = Dir.glob(some_file_path + '/' + '**' + '/')

works as it should on OSX and linux. The same line on Windows:

dirs = Dir.glob(some_file_path + '\\' + '**' + '\\')

returns no directories. What am I doing wrong?

I'm trying to get an array of all of a folders sub folders recursively, and the code above works really nice on a *nix system is there something I need to do differently on windows?

Also note: that on all operating systems I'm using ruby 2.1.5.


Solution

  • Using the '/' will work on Windows as well (Ruby is smart for this).