bfgroup/barbarian

Unclear error message when the git program is not in the path

Closed this issue · 3 comments

It can happen sometimes that I work from a command line window which has not been initiated with the git program in the path. In those cases, when I execute barbarian upload I get the following error:

[INFO] root_dir = C:\Users\user\Source\small3d
[INFO] Uploading revision fdb41a03beedd1e9801df6c042872f84 to C:\Users\user\Source\small3d\.barbarian_upload\small3d\master
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\user\conan-env\Scripts\barbarian.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\conan-env\lib\site-packages\barbarians\barbarian.py", line 709, in main
    Barbarian()
  File "C:\Users\user\conan-env\lib\site-packages\barbarians\barbarian.py", line 94, in __init__
    getattr(self, "command_"+self.args.command)(self.args)
  File "C:\Users\user\conan-env\lib\site-packages\barbarians\barbarian.py", line 395, in command_upload
    self.exec(["git", "remote", "show", "origin"])
  File "C:\Users\user\conan-env\lib\site-packages\barbarians\barbarian.py", line 103, in exec
    result = run(
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Of course, I should make sure that git is in the path so that barbarian can use it to upload packages to github repositories. But this error message can be confusing to new users. If barbarian were to report something like git command not found I think it would greatly enhance user friendliness. It would also reassure users about the robustness of barbarian.

(This is not a serious issue, but rather a suggested enhancement)

I've been taking the stand that seeing stack dumps is a bug. Hence this is definitely something to fix.

Version 0.1.2 with the fix is now live on pypi.

Works like a charm! 💯

(conan-env) C:\Users\user\Source\small3d\conan_io>barbarian upload small3d/master@dimi309/small3d
[INFO] root_dir = C:\Users\user\Source\small3d
[INFO] Uploading revision fdb41a03beedd1e9801df6c042872f84 to C:\Users\user\Source\small3d\.barbarian_upload\small3d\master
[ERROR] Failed to find a "git" program. Using Barbarian requires the "git" program.