Windows: when exceeding maxpath length (260 characters) Middleman throws error even when ignoring the folder

After installing grunt-contrib-imagemin ( npm install grunt-contrib-imagemin --save-dev ) running the command middleman build or bundle exec middleman build generates the below error:

        C:\Users\skezo_000\gitHub\sym-site>middleman build
C:/Ruby200-x64/lib/ruby/2.0.0/pathname.rb:422:in `open': No such file or directory - node_modules/grunt-contrib-imagemin/node_modules/image-min/node_modules/jpegtran-bin/node_modules/bin-wrapper/node_modules/download/node_modules/decompress/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test (Errno::ENOENT)
        from C:/Ruby200-x64/lib/ruby/2.0.0/pathname.rb:422:in `foreach'
        from C:/Ruby200-x64/lib/ruby/2.0.0/pathname.rb:422:in `children'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:126:in `block in all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `flat_map'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/util.rb:122:in `all_files_under'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/core_extensions/file_watcher.rb:134:in `block in reload_path'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/core_extensions/file_watcher.rb:127:in `chdir'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/core_extensions/file_watcher.rb:127:in `reload_path'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/core_extensions/file_watcher.rb:46:in `block in registered'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb:53:in `instance_exec'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb:53:in `block in run_hook_for'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb:49:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb:49:in `run_hook_for'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb:107:in `run_hook'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/core_extensions/request.rb:53:in `inst'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/cli/build.rb:93:in `shared_instance'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/cli/build.rb:62:in `build'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/cli.rb:77:in `method_missing'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:29:in `run'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:128:in `run'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/lib/middleman-core/cli.rb:22:in `start'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.2/bin/middleman:18:in `<top (required)>'
        from C:/Ruby200-x64/bin/middleman:23:in `load'
        from C:/Ruby200-x64/bin/middleman:23:in `<main>'

If I uninstall grunt-contrib-imagemin ( npm uninstall grunt-contrib-imagemin --save-dev ) running the command middleman build or bundle exec middleman build works as expected.

Any reason why this would happen?

This also happens on ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

Tried adding the following into config.rb

config[:file_watcher_ignore] << %r{^node_modules\/}

But no luck getting the same error.

Ok the issue looks like it has to do with total pathlength exceeding 260 characters
http://msdn.microsoft.com/en-us/library/aa365247.aspx#maxpath

What I do not understand is why is Middleman looking in the node_modules folder.

Is there anything else I can do to get middleman to ignore the node_modules folder?

Currently I have tried adding the following to config.rb

  • ignore 'node_modules/*'
  • config[:file_watcher_ignore] << %r{^node_modules\/}

Both did not work. Is there a way to ignore a directory without looking inside it?
I think that is what is causing it to throw the pathlength error.

Looks like this issue might be resolved shortly: