Repository: dbt-labs/dbt-core

Issue:
`dbt deps` fails for non english shells
Please make sure to fill out either the issue template or the feature template and delete the other one!

## Issue
Running `dbt deps` fails on machines with Locale set to any language other than English

### Issue description
The command was (to check Spanish Locale) `LC_ALL=es_ES dbt deps` in a project with packages.yml referring to dbt-utils

### Results
Runs fine with en_US, but failed for Spanish.

### System information
The output of `dbt --version`:
```
₹ dbt --version
installed version: 0.12.1
   latest version: 0.12.1

Up to date!
```

The operating system you're running on: Mac OS Mojave

The python version you're using (probably the output of `python --version`): Python 3.6.5

### Steps to reproduce

Any dbt projects with a one dependency in projects.yml. Here is the output:
```
analytics-core git:(master) 1M 2A ₹ LC_ALL=es_ES dbt deps
Encountered an error:
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 76, in main
    results, succeeded = handle_and_check(args)
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 126, in handle_and_check
    task, res = run_from_args(parsed)
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 181, in run_from_args
    results = run_from_task(task, cfg, parsed)
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 189, in run_from_task
    result = task.run()
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 439, in run
    target_config = final_deps[name].fetch_metadata(self.config)
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 83, in fetch_metadata
    self._cached_metadata = self._fetch_metadata(project)
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 239, in _fetch_metadata
    path = self._checkout(project)
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 235, in _checkout
    dirname=self._checkout_name)
  File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/clients/git.py", line 77, in clone_and_checkout
    directory = matches.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
```


Discussion:
Looks like this is occurring because the code is relying on git command out and err to be in English  https://github.com/fishtown-analytics/dbt/blob/dev/stephen-girard/core/dbt/clients/git.py#L75

Resolving patch:
diff --git a/core/dbt/clients/git.py b/core/dbt/clients/git.py
--- a/core/dbt/clients/git.py
+++ b/core/dbt/clients/git.py
@@ -12,7 +12,7 @@ def clone(repo, cwd, dirname=None, remove_git_dir=False):
     if dirname is not None:
         clone_cmd.append(dirname)
 
-    result = run_cmd(cwd, clone_cmd)
+    result = run_cmd(cwd, clone_cmd, env={'LC_ALL': 'C'})
 
     if remove_git_dir:
         rmdir(os.path.join(dirname, '.git'))
@@ -21,7 +21,7 @@ def clone(repo, cwd, dirname=None, remove_git_dir=False):
 
 
 def list_tags(cwd):
-    out, err = run_cmd(cwd, ['git', 'tag', '--list'])
+    out, err = run_cmd(cwd, ['git', 'tag', '--list'], env={'LC_ALL': 'C'})
     tags = out.decode('utf-8').strip().split("\n")
     return tags
 
@@ -40,7 +40,8 @@ def _checkout(cwd, repo, branch):
     else:
         spec = 'origin/{}'.format(branch)
 
-    out, err = run_cmd(cwd, ['git', 'reset', '--hard', spec])
+    out, err = run_cmd(cwd, ['git', 'reset', '--hard', spec],
+                       env={'LC_ALL': 'C'})
     return out, err
 
 
@@ -55,13 +56,13 @@ def checkout(cwd, repo, branch=None):
 
 
 def get_current_sha(cwd):
-    out, err = run_cmd(cwd, ['git', 'rev-parse', 'HEAD'])
+    out, err = run_cmd(cwd, ['git', 'rev-parse', 'HEAD'], env={'LC_ALL': 'C'})
 
     return out.decode('utf-8')
 
 
 def remove_remote(cwd):
-    return run_cmd(cwd, ['git', 'remote', 'rm', 'origin'])
+    return run_cmd(cwd, ['git', 'remote', 'rm', 'origin'], env={'LC_ALL': 'C'})
 
 
 def clone_and_checkout(repo, cwd, dirname=None, remove_git_dir=False,
diff --git a/core/dbt/clients/system.py b/core/dbt/clients/system.py
--- a/core/dbt/clients/system.py
+++ b/core/dbt/clients/system.py
@@ -268,17 +268,25 @@ def _interpret_oserror(exc, cwd, cmd):
     )
 
 
-def run_cmd(cwd, cmd):
+def run_cmd(cwd, cmd, env=None):
     logger.debug('Executing "{}"'.format(' '.join(cmd)))
     if len(cmd) == 0:
         raise dbt.exceptions.CommandError(cwd, cmd)
 
+    # the env argument replaces the environment entirely, which has exciting
+    # consequences on Windows! Do an update instead.
+    full_env = env
+    if env is not None:
+        full_env = os.environ.copy()
+        full_env.update(env)
+
     try:
         proc = subprocess.Popen(
             cmd,
             cwd=cwd,
             stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE)
+            stderr=subprocess.PIPE,
+            env=full_env)
 
         out, err = proc.communicate()
     except OSError as exc:


Test patch:
diff --git a/test/unit/test_snowflake_adapter.py b/test/unit/test_snowflake_adapter.py
--- a/test/unit/test_snowflake_adapter.py
+++ b/test/unit/test_snowflake_adapter.py
@@ -236,7 +236,7 @@ def test_authenticator_private_key_authentication(self, mock_get_private_key):
         self.snowflake.assert_has_calls([
             mock.call(
                 account='test_account', autocommit=False,
-                client_session_keep_alive=False, database='test_databse',
+                client_session_keep_alive=False, database='test_database',
                 role=None, schema='public', user='test_user',
                 warehouse='test_warehouse', private_key='test_key')
         ])