Berkshelf resolver on Window network home drive slow


#1

Using berks on windows 10 is painfully slow in resolution part. It appears that my .berkshelf directory is being read off my windows shared home drive.

I tried setting the HOME variable and also the BERKSHELF_PATH env variable but I see in the process monitor that the profile is being used. So it turns out that i was not setting the variable correctly in powershell. I needed to $env:BERKSHELF_PATH="<localpath>" instead of Set-Variable or set so that works and speeds up the entire berks program.

Here is how I diagnosed this for anyone who might have this issue in the future.
In the process manager I see repeated access to C:\Windows\CSC\v2.0.6\namespace\<domainname> that are failing over and over. I think this is some caching system.

And then i see access to the berkshelf files :
\\<DOMAIN>\home\<Drive>\<Username>\.berkshelf\cookbooks\iptables-4.3.4\resources

I had opened an issue here https://github.com/berkshelf/berkshelf/issues/1795 but it was closed, I put some details as to what I found.

My next step will be to debug why and how the .berkshelf directory is determined and why the env variables are not being used.

The backtrace shows the cached cookbook loader is slow when I interrupted it

Traceback (most recent call last):
        33: from C:/opscode/chefdk/bin/berks:286:in `<main>'
        32: from C:/opscode/chefdk/bin/berks:286:in `load'
        31: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/bin/berks:5:in `<top (required)>'
        30: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cli.rb:23:in `execute!'
        29: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
        28: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cli.rb:47:in `dispatch'
        27: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        26: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        25: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        24: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cli.rb:131:in `install'
        23: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/berksfile.rb:405:in `install'
        22: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/installer.rb:43:in `run'
        21: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/installer.rb:181:in `install_from_universe'
        20: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/resolver.rb:75:in `resolve'
        19: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/resolver/graph.rb:8:in `populate_store'
        18: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cookbook_store.rb:101:in `cookbooks'
        17: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cookbook_store.rb:101:in `collect'
        16: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cookbook_store.rb:111:in `block in cookbooks'
        15: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cached_cookbook.rb:20:in `from_store_path'
        14: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cached_cookbook.rb:39:in `from_path'
        13: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cached_cookbook.rb:39:in `new'
        12: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cached_cookbook.rb:61:in `initialize'
        11: from C:/opscode/chefdk/embedded/lib/ruby/2.5.0/forwardable.rb:223:in `cookbook_name'
        10: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cached_cookbook.rb:83:in `metadata'
         9: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cached_cookbook.rb:75:in `cookbook_version'
         8: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.4/lib/berkshelf/cached_cookbook.rb:69:in `loader'
         7: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0-universal-mingw32/lib/chef/cookbook/cookbook_version_loader.rb:64:in `load'
         6: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0-universal-mingw32/lib/chef/cookbook/cookbook_version_loader.rb:195:in `load_all_files'
         5: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0-universal-mingw32/lib/chef/cookbook/cookbook_version_loader.rb:195:in `each'
         4: from C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0-universal-mingw32/lib/chef/cookbook/cookbook_version_loader.rb:205:in `block in load_all_files'
         3: from C:/opscode/chefdk/embedded/lib/ruby/2.5.0/find.rb:43:in `find'
         2: from C:/opscode/chefdk/embedded/lib/ruby/2.5.0/find.rb:43:in `collect!'
         1: from C:/opscode/chefdk/embedded/lib/ruby/2.5.0/find.rb:43:in `block in find'