Repository: spyder-ide/spyder

Issue:
spyder 4 startup error
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

Getthign this error each time i start epyder 4. This prpblem was not seen in spyder 3. 

### Traceback
```python-traceback
  File "/home/pratyush/anaconda3/lib/python3.7/site-packages/spyder/plugins/editor/widgets/status.py", line 71, in update_vcs_state
    self.update_vcs(fname, None)
  File "/home/pratyush/anaconda3/lib/python3.7/site-packages/spyder/plugins/editor/widgets/status.py", line 76, in update_vcs
    branches, branch, files_modified = get_git_refs(fpath)
  File "/home/pratyush/anaconda3/lib/python3.7/site-packages/spyder/utils/vcs.py", line 173, in get_git_refs
    cwd=repopath,
  File "/home/pratyush/anaconda3/lib/python3.7/site-packages/spyder/utils/programs.py", line 171, in run_program
    fullcmd = find_program(program)
  File "/home/pratyush/anaconda3/lib/python3.7/site-packages/spyder/utils/programs.py", line 83, in find_program
    path = is_program_installed(name)
  File "/home/pratyush/anaconda3/lib/python3.7/site-packages/spyder/utils/programs.py", line 64, in is_program_installed
    abspath = osp.join(path, basename)
  File "/home/pratyush/anaconda3/lib/python3.7/posixpath.py", line 94, in join
    genericpath._check_arg_types('join', a, *p)
  File "/home/pratyush/anaconda3/lib/python3.7/genericpath.py", line 149, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'
WARNING:spyder.widgets.github.backend:Failed to send bug report on Github. response={'code': 403, 'json': {'message': 'At least one email address must be verified to do that.', 'documentation_url': 'https://help.github.com/articles/adding-an-email-address-to-your-github-account'}}
WARNING:spyder.widgets.github.backend:Failed to send bug report on Github. response={'code': 403, 'json': {'message': 'At least one email address must be verified to do that.', 'documentation_url': 'https://help.github.com/articles/adding-an-email-address-to-your-github-account'}}
```

## Versions

* Spyder version: 4.0.0b2 
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Linux 4.15.0-20-generic

### Dependencies

```
pygments >=2.0     :  2.3.1 (OK)
qdarkstyle >=2.6.4 :  2.6.8 (OK)
sphinx >=0.6.6     :  1.8.5 (OK)
psutil >=0.3       :  5.6.1 (OK)
pyls >=0.19.0;<0.25:  0.24.0 (OK)
nbconvert >=4.0    :  5.4.1 (OK)
pandas >=0.13.1    :  0.24.2 (OK)
numpy >=1.7        :  1.16.2 (OK)
sympy >=0.7.3      :  1.3 (OK)
cython >=0.21      :  0.29.6 (OK)
qtconsole >=4.2.0  :  4.4.3 (OK)
IPython >=4.0      :  7.4.0 (OK)
matplotlib >=2.0.0 :  3.0.3 (OK)
pylint >=0.25      :  2.3.1 (OK)
```



Discussion:
Thanks for reporting. We'll try to fix this error in our next beta.

@goanpeca, this seems related to showing the current git branch in the status bar. Please take a look at it.

Resolving patch:
diff --git a/spyder/utils/vcs.py b/spyder/utils/vcs.py
--- a/spyder/utils/vcs.py
+++ b/spyder/utils/vcs.py
@@ -163,48 +163,48 @@ def get_git_refs(repopath):
     if os.path.isfile(repopath):
         repopath = os.path.dirname(repopath)
 
-    try:
-
-        git = programs.find_program('git')
-
-        # Files modified
-        out, err = programs.run_program(
-            git, ['status', '-s'],
-            cwd=repopath,
-        ).communicate()
-
-        if PY3:
-            out = out.decode(sys.getdefaultencoding())
-        files_modifed = [line.strip() for line in out.split('\n') if line]
-
-        # Tags
-        out, err = programs.run_program(
-            git, ['tag'],
-            cwd=repopath,
-        ).communicate()
-
-        if PY3:
-            out = out.decode(sys.getdefaultencoding())
-        tags = [line.strip() for line in out.split('\n') if line]
-
-        # Branches
-        out, err = programs.run_program(
-            git, ['branch', '-a'],
-            cwd=repopath,
-        ).communicate()
-
-        if PY3:
-            out = out.decode(sys.getdefaultencoding())
-
-        lines = [line.strip() for line in out.split('\n') if line]
-        for line in lines:
-            if line.startswith('*'):
-                line = line.replace('*', '').strip()
-                branch = line
-
-            branches.append(line)
-
-    except (subprocess.CalledProcessError, AttributeError, OSError):
-        pass
+    git = programs.find_program('git')
+
+    if git:
+        try:
+            # Files modified
+            out, err = programs.run_program(
+                git, ['status', '-s'],
+                cwd=repopath,
+            ).communicate()
+
+            if PY3:
+                out = out.decode(sys.getdefaultencoding())
+            files_modifed = [line.strip() for line in out.split('\n') if line]
+
+            # Tags
+            out, err = programs.run_program(
+                git, ['tag'],
+                cwd=repopath,
+            ).communicate()
+
+            if PY3:
+                out = out.decode(sys.getdefaultencoding())
+            tags = [line.strip() for line in out.split('\n') if line]
+
+            # Branches
+            out, err = programs.run_program(
+                git, ['branch', '-a'],
+                cwd=repopath,
+            ).communicate()
+
+            if PY3:
+                out = out.decode(sys.getdefaultencoding())
+
+            lines = [line.strip() for line in out.split('\n') if line]
+            for line in lines:
+                if line.startswith('*'):
+                    line = line.replace('*', '').strip()
+                    branch = line
+
+                branches.append(line)
+
+        except (subprocess.CalledProcessError, AttributeError, OSError):
+            pass
 
     return branches + tags, branch, files_modifed


Test patch:
diff --git a/spyder/utils/tests/test_vcs.py b/spyder/utils/tests/test_vcs.py
--- a/spyder/utils/tests/test_vcs.py
+++ b/spyder/utils/tests/test_vcs.py
@@ -19,6 +19,7 @@
 # Local imports
 from spyder.utils.vcs import (ActionToolNotFound, get_git_refs,
                               get_git_revision, get_vcs_root, run_vcs_tool)
+from spyder.utils import programs
 
 
 @pytest.mark.skipif(os.environ.get('CI', None) is None,
@@ -46,6 +47,18 @@ def test_git_revision():
     assert all([isinstance(x, str) for x in get_git_revision(root)])
 
 
+def test_no_git(monkeypatch):
+
+    def mockreturn(program_name):
+        return None
+
+    monkeypatch.setattr(programs, 'find_program', mockreturn)
+    branch_tags, branch, files_modified = get_git_refs(__file__)
+    assert len(branch_tags) == 0
+    assert branch == ''
+    assert len(files_modified) == 0
+
+
 def test_get_git_refs():
     branch_tags, branch, files_modified = get_git_refs(__file__)
     assert bool(branch)  # This must always return a branch_name