Repository: conda/conda-build

Issue:
Unhelpful error message
I regularly get the error

```FileNotFoundError: [WinError 2] The system cannot find the file specified```

when running `conda build` (notably in a new environment that doesn't yet have all the required tools.
It would be good if the error above could include the name of the file that is missing.
(Here is a more complete traceback:
```
Traceback (most recent call last):
  File "C:\Users\stefan\Anaconda3\Scripts\conda-build-script.py", line 5, in <module>
    sys.exit(conda_build.cli.main_build.main())
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\cli\main_build.py", line 322, in main
    execute(sys.argv[1:])
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\cli\main_build.py", line 313, in execute
    noverify=args.no_verify)
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\api.py", line 97, in build
    need_source_download=need_source_download, config=config)
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\build.py", line 1493, in build_tree
    config=config)
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\build.py", line 1143, in build
    built_package = bundlers[output_dict.get('type', 'conda')](output_dict, m, config, env)
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\build.py", line 890, in bundle_conda
    create_info_files(tmp_metadata, files, config=config, prefix=config.build_prefix)
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\build.py", line 510, in create_info_files
    source.git_info(config, fo)
  File "C:\Users\stefan\Anaconda3\lib\site-packages\conda_build\source.py", line 266, in git_info
    p = Popen(cmd.split(), stdout=PIPE, stderr=PIPE, cwd=config.work_dir, env=env)
  File "C:\Users\stefan\Anaconda3\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\stefan\Anaconda3\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
```
i.e.,  it appears `conda build` is trying to run some tool such as `git` or `cygpath` or similar. Right now I need to modify the code to print out the missing info, which obviously isn't the right way to solve this.)


Discussion:

Resolving patch:
diff --git a/conda_build/source.py b/conda_build/source.py
--- a/conda_build/source.py
+++ b/conda_build/source.py
@@ -5,7 +5,7 @@
 import os
 from os.path import join, isdir, isfile, abspath, basename, exists, normpath
 import re
-from subprocess import Popen, PIPE, CalledProcessError
+from subprocess import CalledProcessError
 import sys
 import time
 
@@ -224,7 +224,7 @@ def git_source(metadata, config):
 
     git = external.find_executable('git')
     if not git:
-        sys.exit("Error: git is not installed")
+        sys.exit("Error: git is not installed in your root environment.")
 
     meta = metadata.get_section('source')
 
@@ -254,6 +254,18 @@ def git_info(config, fo=None):
     ''' Print info about a Git repo. '''
     assert isdir(config.work_dir)
 
+    git = external.find_executable('git')
+    if not git:
+        log = logging.getLogger(__name__)
+        log.warn("git not installed in root environment.  Skipping recording of git info.")
+        return
+
+    if config.verbose:
+        stderr = None
+    else:
+        FNULL = open(os.devnull, 'w')
+        stderr = FNULL
+
     # Ensure to explicitly set GIT_DIR as some Linux machines will not
     # properly execute without it.
     env = os.environ.copy()
@@ -263,16 +275,17 @@ def git_info(config, fo=None):
             ('git log -n1', True),
             ('git describe --tags --dirty', False),
             ('git status', True)]:
-        p = Popen(cmd.split(), stdout=PIPE, stderr=PIPE, cwd=config.work_dir, env=env)
-        stdout, stderr = p.communicate()
+        try:
+            stdout = check_output_env(cmd.split(), stderr=stderr, cwd=config.work_dir, env=env)
+        except CalledProcessError as e:
+            if check_error:
+                raise Exception("git error: %s" % str(e))
         encoding = locale.getpreferredencoding()
         if not fo:
             encoding = sys.stdout.encoding
         encoding = encoding or 'utf-8'
-        stdout = stdout.decode(encoding, 'ignore')
-        stderr = stderr.decode(encoding, 'ignore')
-        if check_error and stderr and stderr.strip():
-            raise Exception("git error: %s" % stderr)
+        if hasattr(stdout, 'decode'):
+            stdout = stdout.decode(encoding, 'ignore')
         if fo:
             fo.write(u'==> %s <==\n' % cmd)
             if config.verbose:


Test patch: