Repository: conda/conda-build

Issue:
Strange error on Windows 8 build...
Trying to build a package that successfully builds on mac and unix on Windows 8 (praxes/hexrd) and I get the following error:

C:\Users\Diwakar\Documents\GitHub\hexrd>conda build conda.recipe
An unexpected error has occurred, please consider sending the
following traceback to the conda GitHub issue tracker at:

```
https://github.com/conda/conda-build/issues
```

Include the output of the command 'conda info' in your report.

Traceback (most recent call last):
  File "C:\Users\Diwakar\Anaconda\Scripts\conda-build-script.py", line 4, in <module>
    sys.exit(main())
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\main_build.py", line 110, in main
    args_func(args, p)
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\main_build.py", line 312, in args_func
    args.func(args, p)
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\main_build.py", line 244, in execute
    m = MetaData(recipe_dir)
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\metadata.py", line 250, in **init**
    self.parse_again()
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\metadata.py", line 258, in parse_again
    self.meta = parse(get_contents(self.meta_path))
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\metadata.py", line 230, in get_contents
    env.globals.update(context_processor())
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\jinja_context.py", line 45, in context_processor
    ctx = get_environ()
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\environ.py", line 91, in get_dict
    d.update(**get_git_build_info(d['SRC_DIR']))
  File "C:\Users\Diwakar\Anaconda\lib\site-packages\conda_build\environ.py", line 43, in get_git_build_info
    env=env)
  File "C:\Users\Diwakar\Anaconda\lib\subprocess.py", line 710, in **init**
    errread, errwrite)
  File "C:\Users\Diwakar\Anaconda\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Here's the  environment for reference:

C:\Users\Diwakar\Documents\GitHub\hexrd>conda list
# packages in environment at C:\Users\Diwakar\Anaconda:
# 

_license                  1.1                      py27_0
anaconda                  2.1.0                np19py27_0
argcomplete               0.8.1                    py27_0
astropy                   0.4.2                np19py27_0
atom                      0.3.9                    py27_0
backports.ssl-match-hostname 3.4.0.2                   <p
beautiful-soup            4.3.2                    py27_0
beautifulsoup4            4.3.2                     <pip>
binstar                   0.9.5                    py27_0
bitarray                  0.8.1                    py27_1
blaze                     0.6.3                np19py27_0
blz                       0.6.2                np19py27_0
bokeh                     0.6.1                np19py27_0
boto                      2.32.1                   py27_0
casuarius                 1.1                      py27_0
cdecimal                  2.3                      py27_1
cffi                      0.8.6                    py27_0
chaco                     4.4.1                np19py27_0
clyent                    0.3.2                    py27_0
colorama                  0.3.1                    py27_0
conda                     3.7.3                    py27_0
conda-build               1.9.1                    py27_0
configobj                 5.0.6                    py27_0
cryptography              0.5.4                    py27_0
cython                    0.21                     py27_0
cytoolz                   0.7.0                    py27_0
datashape                 0.3.0                np19py27_1
dateutil                  2.1                      py27_2
decorator                 3.4.0                    py27_0
docutils                  0.12                     py27_0
dynd-python               0.6.5                np19py27_0
enable                    4.3.0                np19py27_2
enaml                     0.9.8                    py27_0
flask                     0.10.1                   py27_1
future                    0.13.1                   py27_0
futures                   2.1.6                    py27_0
gevent                    1.0.1                    py27_0
gevent-websocket          0.9.3                    py27_0
greenlet                  0.4.4                    py27_0
grin                      1.2.1                    py27_2
h5py                      2.3.1                np19py27_0
hexrd                     unknown                   <pip>
ipython                   2.2.0                    py27_0
ipython-notebook          2.2.0                    py27_0
ipython-qtconsole         2.2.0                    py27_0
itsdangerous              0.24                     py27_0
jdcal                     1.0                      py27_0
jinja2                    2.7.3                    py27_1
kiwisolver                0.1.3                    py27_0
launcher                  1.0.0                         1
libpython                 1.0                      py27_1
llvmpy                    0.12.7                   py27_0
lxml                      3.4.0                    py27_0
markupsafe                0.23                     py27_0
matplotlib                1.4.2                np19py27_0
menuinst                  1.0.4                    py27_0
mingw                     4.7                           1
mock                      1.0.1                    py27_0
multipledispatch          0.4.7                    py27_0
networkx                  1.9.1                    py27_0
nltk                      3.0.0                np19py27_0
node-webkit               0.10.1                        0
nose                      1.3.4                    py27_0
numba                     0.14.0               np19py27_0
numexpr                   2.3.1                np19py27_0
numpy                     1.9.1                    py27_0
openpyxl                  1.8.5                    py27_0
pandas                    0.14.1               np19py27_0
patsy                     0.3.0                np19py27_0
pep8                      1.5.7                    py27_0
pil                       1.1.7                    py27_0
pip                       1.5.6                    py27_0
ply                       3.4                      py27_0
psutil                    2.1.1                    py27_0
py                        1.4.25                   py27_0
pycosat                   0.6.1                    py27_0
pycparser                 2.10                     py27_0
pycrypto                  2.6.1                    py27_2
pyface                    4.4.0                    py27_0
pyflakes                  0.8.1                    py27_0
pygments                  1.6                      py27_0
pyopenssl                 0.14                     py27_0
pyparsing                 2.0.1                    py27_0
pyqt                      4.10.4                   py27_0
pyreadline                2.0                      py27_0
pytables                  3.1.1                np19py27_1
pytest                    2.6.3                    py27_0
python                    2.7.8                         0
python-dateutil           1.5                       <pip>
pytz                      2014.9                   py27_0
pywin32                   219                      py27_0
pyyaml                    3.11                     py27_0
pyzmq                     14.3.1                   py27_0
requests                  2.5.0                    py27_0
rope                      0.9.4                    py27_1
runipy                    0.1.1                    py27_0
scikit-image              0.10.1               np19py27_0
scikit-learn              0.15.2               np19py27_0
scipy                     0.14.0               np19py27_0
setuptools                7.0                      py27_0
six                       1.8.0                    py27_0
sockjs-tornado            1.0.1                    py27_0
sphinx                    1.2.3                    py27_0
spyder                    2.3.1                    py27_0
spyder-app                2.3.1                    py27_0
sqlalchemy                0.9.7                    py27_0
ssl_match_hostname        3.4.0.2                  py27_0
statsmodels               0.5.0                np19py27_2
sympy                     0.7.5                    py27_0
tables                    3.1.1                     <pip>
toolz                     0.7.0                    py27_0
tornado                   4.0.2                    py27_0
traits                    4.4.0                    py27_0
traitsui                  4.4.0                    py27_0
ujson                     1.33                     py27_0
unicodecsv                0.9.4                    py27_0
werkzeug                  0.9.6                    py27_1
wsgiref                   0.1.2                     <pip>
wxpython                  3.0                      py27_0
xlrd                      0.9.3                    py27_0
xlsxwriter                0.5.7                    py27_0
xlwings                   0.2.2                    py27_0
xlwt                      0.7.5                    py27_0



Discussion:
I have seen this error multiple times when I didn't have `git` on my `%PATH%`.
Yes, we need a better error message here.  Thanks for re-raising this issue.

Resolving patch:
diff --git a/conda_build/os_utils/external.py b/conda_build/os_utils/external.py
--- a/conda_build/os_utils/external.py
+++ b/conda_build/os_utils/external.py
@@ -5,6 +5,7 @@
 from os.path import isfile, join, expanduser
 
 from conda_build.conda_interface import root_dir
+from conda_build.exceptions import RecipeError
 
 
 def find_executable(executable, prefix=None):
@@ -39,3 +40,7 @@ def find_executable(executable, prefix=None):
             exp_path = expanduser(path)
             if isfile(exp_path) and os.access(exp_path, os.X_OK):
                 return expanduser(path)
+    raise RecipeError("Your recipe requires '{}', but this executable is unavailable.  Please "
+                      "install a package containing that executable into either your root "
+                      "environment or your build requirements, or otherwise make this executable "
+                      "available on PATH.".format(executable))


Test patch:
diff --git a/tests/test_os_utils_external.py b/tests/test_os_utils_external.py
--- a/tests/test_os_utils_external.py
+++ b/tests/test_os_utils_external.py
@@ -2,7 +2,11 @@
 import os
 import os.path
 
+import pytest
+
 from conda_build.os_utils.external import find_executable
+from conda_build.exceptions import RecipeError
+
 
 def test_find_executable(testing_workdir, monkeypatch):
     if sys.platform != "win32":
@@ -52,3 +56,8 @@ def create_file(unix_path, put_on_path, executable):
         find = find_executable('target_name')
 
         assert find == target_path, "Expected to find 'target_name' in '%s', but found it in '%s'" % (target_path, find)
+
+
+def test_find_executable_raises_on_not_found():
+    with pytest.raises(RecipeError):
+        find_executable('does_not_exist')