Repository: xonsh/xonsh

Issue:
Unhandled KeyError on missing color scheme with `xonsh --no-rc`
<!--- Provide a general summary of the issue in the Title above -->
<!--- If you have a question along the lines of "How do I do this Bash command in xonsh"
please first look over the Bash to Xonsh translation guide: https://xon.sh/bash_to_xsh.html
If you don't find an answer there, please do open an issue! -->

## xonfig

<details>

```
[Ryans-MacBook-Pro:~] ryan% xonsh -c 'xonfig'
<xonsh-code>:1:0 - xonfig
<xonsh-code>:1:0 + ![xonfig]
+------------------+-----------------+
| xonsh            | 0.13.0          |
| Python           | 3.10.2          |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | None            |
| shell type       | none            |
| history backend  | sqlite          |
| pygments         | None            |
| on posix         | True            |
| on linux         | False           |
| on darwin        | True            |
| on windows       | False           |
| on cygwin        | False           |
| on msys2         | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
| xontrib          | []              |
| RC file          | []              |
+------------------+-----------------+
```

</details>

## Expected Behavior
xonsh should start.

## Current Behavior

<details>

```
[Ryans-MacBook-Pro:~] ryan% bash -c 'env XONSH_DEBUG=1 XONSH_SHOW_TRACEBACK=True xonsh --no-rc'
Traceback (most recent call last):
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/main.py", line 467, in main
    args = premain(argv)
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/main.py", line 407, in premain
    env = start_services(shell_kwargs, args, pre_env=pre_env)
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/main.py", line 355, in start_services
    XSH.shell = Shell(execer=execer, **shell_kwargs)
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/shell.py", line 224, in __init__
    env=env.detype(),
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/environ.py", line 1906, in detype
    deval = detyper(val)
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/tools.py", line 1240, in detype
    return x.detype()
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/environ.py", line 404, in detype
    style = self.style
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/environ.py", line 438, in style
    self._style = ansi_style_by_name(style_name)
  File "/Users/ryan/.local/lib/python3.10/site-packages/xonsh/ansi_colors.py", line 1152, in ansi_style_by_name
    raise KeyError(f"could not find style {name!r}")
KeyError: "could not find style 'gruvbox'"
Xonsh encountered an issue during launch
Failback to /bin/csh
```

</details>


## Steps to Reproduce
<!--- Please try to write out a minimal reproducible snippet to trigger the bug, it will help us fix it! -->

I'm currently debugging my [xontrib-gruvbox](https://github.com/rpdelaney/xontrib-gruvbox) to figure out what I did wrong with packaging it that might be causing this. In the mean time, xonsh should handle this situation more gracefully.

## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**



Discussion:

Resolving patch:
diff --git a/xonsh/ansi_colors.py b/xonsh/ansi_colors.py
--- a/xonsh/ansi_colors.py
+++ b/xonsh/ansi_colors.py
@@ -1149,7 +1149,8 @@ def ansi_style_by_name(name):
     if name in ANSI_STYLES:
         return ANSI_STYLES[name]
     elif not HAS_PYGMENTS:
-        raise KeyError(f"could not find style {name!r}")
+        print(f"could not find style {name!r}, using 'default'")
+        return ANSI_STYLES["default"]
     from pygments.util import ClassNotFound
 
     from xonsh.pygments_cache import get_style_by_name


Test patch: