    # File lib/chef/knife.rb, line 286
        def configure_chef
          unless config[:config_file]
            candidate_configs = []

            # Look for $KNIFE_HOME/knife.rb (allow multiple knives config on same machine)
            if ENV['KNIFE_HOME']
              candidate_configs << File.join(ENV['KNIFE_HOME'], 'knife.rb')
            end
            # Look for $PWD/knife.rb
            if Dir.pwd
              candidate_configs << File.join(Dir.pwd, 'knife.rb')
            end
            # Look for $UPWARD/.chef/knife.rb
            if self.class.chef_config_dir
              candidate_configs << File.join(self.class.chef_config_dir, 'knife.rb')
            end
            # Look for $HOME/.chef/knife.rb
            if ENV['HOME']
              candidate_configs << File.join(ENV['HOME'], '.chef', 'knife.rb')
            end

            candidate_configs.each do | candidate_config |
              candidate_config = File.expand_path(candidate_config)
              if File.exist?(candidate_config)
                config[:config_file] = candidate_config
                break
              end
            end
          end

          # Don't try to load a knife.rb if it doesn't exist.
          if config[:config_file]
            read_config_file(config[:config_file])
          else
            # ...but do log a message if no config was found.
            Chef::Config[:color] = config[:color]
            ui.warn("No knife configuration file found")
          end

          Chef::Config[:color] = config[:color]

          case Chef::Config[:verbosity]
          when 0
            Chef::Config[:log_level] = :error
          when 1
            Chef::Config[:log_level] = :info
          else
            Chef::Config[:log_level] = :debug
          end

          Chef::Config[:node_name]         = config[:node_name]       if config[:node_name]
          Chef::Config[:client_key]        = config[:client_key]      if config[:client_key]
          Chef::Config[:chef_server_url]   = config[:chef_server_url] if config[:chef_server_url]
          Chef::Config[:environment]       = config[:environment]     if config[:environment]

          # Expand a relative path from the config directory. Config from command
          # line should already be expanded, and absolute paths will be unchanged.
          if Chef::Config[:client_key] && config[:config_file]
            Chef::Config[:client_key] = File.expand_path(Chef::Config[:client_key], File.dirname(config[:config_file]))
          end

          Mixlib::Log::Formatter.show_time = false
          Chef::Log.init(Chef::Config[:log_location])
          Chef::Log.level(Chef::Config[:log_level] || :error)

          Chef::Log.debug("Using configuration from #{config[:config_file]}")

          if Chef::Config[:node_name] && Chef::Config[:node_name].bytesize > 90
            # node names > 90 bytes only work with authentication protocol >= 1.1
            # see discussion in config.rb.
            Chef::Config[:authentication_protocol_version] = "1.1"
          end
        end