Repository: xonsh/xonsh

Issue:
Broken symlink on path causes crash on Windows
Installed latest xonsh (0.8.8) on Windows according to recommended procedure from documentation.
Upon running "xonsh" from the command prompt, I get a Traceback:

```
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\Scripts\xonsh-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 23278, in main
    _failback_to_other_shells(args, err)
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 23247, in _failback_to_other_shells
    raise err
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 23275, in main
    args = premain(argv)
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 23226, in premain
    env = start_services(shell_kwargs, args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 23161, in start_services
    cacheall=shell_kwargs.get("cacheall", False),
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 22297, in __init__
    load_builtins(execer=self, ctx=xonsh_ctx)
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 21869, in load_builtins
    builtins.__xonsh__.link_builtins(execer=execer)
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 21999, in link_builtins
    builtins.default_aliases = builtins.aliases = Aliases(make_default_aliases())
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 20598, in make_default_aliases
    if not locate_binary("sudo"):
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 17957, in locate_binary
    return builtins.__xonsh__.commands_cache.locate_binary(name)
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 7584, in locate_binary
    _ = self.all_commands
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 7527, in all_commands
    for cmd in executables_in(path):
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 4715, in executables_in
    yield from func(path)
  File "C:\ProgramData\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 4699, in _executables_in_windows
    if x.is_file():
OSError: [WinError 1921] The name of the file cannot be resolved by the system: 'C:\\WINDOWS\\LastGood.Tmp'

I then confirmed 'C:\\WINDOWS\\LastGood.Tmp' is indeed a broken symlink folder.

11/03/2017  10:37 AM    <SYMLINKD>     LastGood.Tmp [C:\\C:\Windows\LastGood.Tmp]

C:\Users\chad>dir c:\Windows\LastGood.Tmp

 Directory of c:\Windows\LastGood.Tmp

File Not Found
```

This is related to issue #1041

## Expected Behavior
Not crashing at startup regardless of broken symlink folders on path

## Current Behavior
Crashing at startup when broken symlink folder on path

## Steps to Reproduce
Make a broken symlink on Windows somewhere on the path. Start xonsh.


Discussion:

Resolving patch:
diff --git a/xonsh/tools.py b/xonsh/tools.py
--- a/xonsh/tools.py
+++ b/xonsh/tools.py
@@ -790,7 +790,11 @@ def _executables_in_windows(path):
                     yield fname
     else:
         for x in scandir(path):
-            if x.is_file():
+            try:
+                is_file = x.is_file()
+            except OSError:
+                continue
+            if is_file:
                 fname = x.name
             else:
                 continue


Test patch: