We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Feature-request: Static configuration file as a command line option
I suggest that an option to the commandline --config_file is added that allows the user to specify a file location for a static configuration file. (http://xonsh.org/xonshconfig.html)

This would allow portable usage of xonsh, e.g. install python and xonsh on a usb and bring the shell on a stick. 


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `xonsh/main.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 """The main xonsh script."""
3 import os
4 import sys
5 import shlex
6 import signal
7 import builtins
8 import subprocess
9 from argparse import ArgumentParser, Namespace
10 from contextlib import contextmanager
11 
12 from xonsh import __version__
13 from xonsh.shell import Shell
14 from xonsh.pretty import pprint
15 from xonsh.jobs import ignore_sigtstp
16 
17 parser = ArgumentParser(description='xonsh')
18 parser.add_argument('-V', '--version',
19                     action='version',
20                     version='/'.join(('xonsh', __version__)),
21                     help='show version information and exit')
22 parser.add_argument('-c',
23                     help="Run a single command and exit",
24                     dest='command',
25                     required=False,
26                     default=None)
27 parser.add_argument('-i',
28                     help='force running in interactive mode',
29                     dest='force_interactive',
30                     action='store_true',
31                     default=False)
32 parser.add_argument('-l',
33                     help='run as a login shell',
34                     dest='login',
35                     action='store_true',
36                     default=False)
37 parser.add_argument('--no-rc',
38                     help="Do not load the .xonshrc file",
39                     dest='norc',
40                     action='store_true',
41                     default=False)
42 parser.add_argument('-D',
43                     dest='defines',
44                     help='define an environment variable, in the form of '
45                          '-DNAME=VAL. May be used many times.',
46                     metavar='ITEM',
47                     nargs='*',
48                     default=None)
49 parser.add_argument('--shell-type',
50                     help='What kind of shell should be used. '
51                          'Possible options: readline, prompt_toolkit. '
52                          'Warning! If set this overrides $SHELL_TYPE variable.',
53                     dest='shell_type',
54                     choices=('readline', 'prompt_toolkit'),
55                     default=None)
56 parser.add_argument('file',
57                     metavar='script-file',
58                     help='If present, execute the script in script-file'
59                          ' and exit',
60                     nargs='?',
61                     default=None)
62 parser.add_argument('args',
63                     metavar='args',
64                     help='Additional arguments to the script specified'
65                          ' by script-file',
66                     nargs='*',
67                     default=[])
68 
69 
70 def _pprint_displayhook(value):
71     if value is not None:
72         builtins._ = value
73         pprint(value)
74 
75 
76 def premain(argv=None):
77     """Setup for main xonsh entry point, returns parsed arguments."""
78     args = parser.parse_args(argv)
79     shell_kwargs = {'shell_type': args.shell_type}
80     if args.norc:
81         shell_kwargs['ctx'] = {}
82     setattr(sys, 'displayhook', _pprint_displayhook)
83     shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)
84     from xonsh import imphooks
85     env = builtins.__xonsh_env__
86     if args.defines is not None:
87         env.update([x.split('=', 1) for x in args.defines])
88     if args.login:
89         env['XONSH_LOGIN'] = True
90     env['XONSH_INTERACTIVE'] = False
91     return args
92 
93 
94 def main(argv=None):
95     """Main entry point for xonsh cli."""
96     args = premain(argv)
97     env = builtins.__xonsh_env__
98     shell = builtins.__xonsh_shell__
99     if args.command is not None:
100         # run a single command and exit
101         shell.default(args.command)
102     elif args.file is not None:
103         # run a script contained in a file
104         if os.path.isfile(args.file):
105             with open(args.file) as f:
106                 code = f.read()
107             code = code if code.endswith('\n') else code + '\n'
108             env['ARGS'] = [args.file] + args.args
109             code = shell.execer.compile(code, mode='exec', glbs=shell.ctx)
110             shell.execer.exec(code, mode='exec', glbs=shell.ctx)
111         else:
112             print('xonsh: {0}: No such file or directory.'.format(args.file))
113     elif not sys.stdin.isatty() and not args.force_interactive:
114         # run a script given on stdin
115         code = sys.stdin.read()
116         code = code if code.endswith('\n') else code + '\n'
117         code = shell.execer.compile(code, mode='exec', glbs=shell.ctx)
118         shell.execer.exec(code, mode='exec', glbs=shell.ctx)
119     else:
120         # otherwise, enter the shell
121         env['XONSH_INTERACTIVE'] = True
122         ignore_sigtstp()
123         shell.cmdloop()
124     postmain(args)
125 
126 
127 def postmain(args=None):
128     """Teardown for main xonsh entry point, accepts parsed arguments."""
129     del builtins.__xonsh_shell__
130 
131 
132 @contextmanager
133 def main_context(argv=None):
134     """Generator that runs pre- and post-main() functions. This has two iterations.
135     The first yields the shell. The second returns None but cleans
136     up the shell.
137     """
138     args = premain(argv)
139     yield builtins.__xonsh_shell__
140     postmain(args)
141 
142 
143 
144 if __name__ == '__main__':
145     main()
146
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/xonsh/main.py b/xonsh/main.py
--- a/xonsh/main.py
+++ b/xonsh/main.py
@@ -2,11 +2,8 @@
 """The main xonsh script."""
 import os
 import sys
-import shlex
-import signal
 import builtins
-import subprocess
-from argparse import ArgumentParser, Namespace
+from argparse import ArgumentParser, ArgumentTypeError
 from contextlib import contextmanager
 
 from xonsh import __version__
@@ -14,6 +11,18 @@
 from xonsh.pretty import pprint
 from xonsh.jobs import ignore_sigtstp
 
+def path_argument(s):
+    """Return a path only if the path is actually legal
+
+    This is very similar to argparse.FileType, except that it doesn't return
+    an open file handle, but rather simply validates the path."""
+
+    s = os.path.abspath(os.path.expanduser(s))
+    if not os.path.isfile(s):
+        raise ArgumentTypeError('"%s" must be a valid path to a file' % s)
+    return s
+
+
 parser = ArgumentParser(description='xonsh')
 parser.add_argument('-V', '--version',
                     action='version',
@@ -34,6 +43,10 @@
                     dest='login',
                     action='store_true',
                     default=False)
+parser.add_argument('--config-path',
+                    help='specify a custom static configuration file',
+                    dest='config_path',
+                    type=path_argument)
 parser.add_argument('--no-rc',
                     help="Do not load the .xonshrc file",
                     dest='norc',
@@ -79,6 +92,8 @@
     shell_kwargs = {'shell_type': args.shell_type}
     if args.norc:
         shell_kwargs['ctx'] = {}
+    if args.config_path:
+        shell_kwargs['ctx']= {'XONSHCONFIG': args.config_path}
     setattr(sys, 'displayhook', _pprint_displayhook)
     shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)
     from xonsh import imphooks

{"golden_diff": "diff --git a/xonsh/main.py b/xonsh/main.py\n--- a/xonsh/main.py\n+++ b/xonsh/main.py\n@@ -2,11 +2,8 @@\n \"\"\"The main xonsh script.\"\"\"\n import os\n import sys\n-import shlex\n-import signal\n import builtins\n-import subprocess\n-from argparse import ArgumentParser, Namespace\n+from argparse import ArgumentParser, ArgumentTypeError\n from contextlib import contextmanager\n \n from xonsh import __version__\n@@ -14,6 +11,18 @@\n from xonsh.pretty import pprint\n from xonsh.jobs import ignore_sigtstp\n \n+def path_argument(s):\n+    \"\"\"Return a path only if the path is actually legal\n+\n+    This is very similar to argparse.FileType, except that it doesn't return\n+    an open file handle, but rather simply validates the path.\"\"\"\n+\n+    s = os.path.abspath(os.path.expanduser(s))\n+    if not os.path.isfile(s):\n+        raise ArgumentTypeError('\"%s\" must be a valid path to a file' % s)\n+    return s\n+\n+\n parser = ArgumentParser(description='xonsh')\n parser.add_argument('-V', '--version',\n                     action='version',\n@@ -34,6 +43,10 @@\n                     dest='login',\n                     action='store_true',\n                     default=False)\n+parser.add_argument('--config-path',\n+                    help='specify a custom static configuration file',\n+                    dest='config_path',\n+                    type=path_argument)\n parser.add_argument('--no-rc',\n                     help=\"Do not load the .xonshrc file\",\n                     dest='norc',\n@@ -79,6 +92,8 @@\n     shell_kwargs = {'shell_type': args.shell_type}\n     if args.norc:\n         shell_kwargs['ctx'] = {}\n+    if args.config_path:\n+        shell_kwargs['ctx']= {'XONSHCONFIG': args.config_path}\n     setattr(sys, 'displayhook', _pprint_displayhook)\n     shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)\n     from xonsh import imphooks\n", "issue": "Feature-request: Static configuration file as a command line option\nI suggest that an option to the commandline --config_file is added that allows the user to specify a file location for a static configuration file. (http://xonsh.org/xonshconfig.html)\n\nThis would allow portable usage of xonsh, e.g. install python and xonsh on a usb and bring the shell on a stick. \n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"The main xonsh script.\"\"\"\nimport os\nimport sys\nimport shlex\nimport signal\nimport builtins\nimport subprocess\nfrom argparse import ArgumentParser, Namespace\nfrom contextlib import contextmanager\n\nfrom xonsh import __version__\nfrom xonsh.shell import Shell\nfrom xonsh.pretty import pprint\nfrom xonsh.jobs import ignore_sigtstp\n\nparser = ArgumentParser(description='xonsh')\nparser.add_argument('-V', '--version',\n                    action='version',\n                    version='/'.join(('xonsh', __version__)),\n                    help='show version information and exit')\nparser.add_argument('-c',\n                    help=\"Run a single command and exit\",\n                    dest='command',\n                    required=False,\n                    default=None)\nparser.add_argument('-i',\n                    help='force running in interactive mode',\n                    dest='force_interactive',\n                    action='store_true',\n                    default=False)\nparser.add_argument('-l',\n                    help='run as a login shell',\n                    dest='login',\n                    action='store_true',\n                    default=False)\nparser.add_argument('--no-rc',\n                    help=\"Do not load the .xonshrc file\",\n                    dest='norc',\n                    action='store_true',\n                    default=False)\nparser.add_argument('-D',\n                    dest='defines',\n                    help='define an environment variable, in the form of '\n                         '-DNAME=VAL. May be used many times.',\n                    metavar='ITEM',\n                    nargs='*',\n                    default=None)\nparser.add_argument('--shell-type',\n                    help='What kind of shell should be used. '\n                         'Possible options: readline, prompt_toolkit. '\n                         'Warning! If set this overrides $SHELL_TYPE variable.',\n                    dest='shell_type',\n                    choices=('readline', 'prompt_toolkit'),\n                    default=None)\nparser.add_argument('file',\n                    metavar='script-file',\n                    help='If present, execute the script in script-file'\n                         ' and exit',\n                    nargs='?',\n                    default=None)\nparser.add_argument('args',\n                    metavar='args',\n                    help='Additional arguments to the script specified'\n                         ' by script-file',\n                    nargs='*',\n                    default=[])\n\n\ndef _pprint_displayhook(value):\n    if value is not None:\n        builtins._ = value\n        pprint(value)\n\n\ndef premain(argv=None):\n    \"\"\"Setup for main xonsh entry point, returns parsed arguments.\"\"\"\n    args = parser.parse_args(argv)\n    shell_kwargs = {'shell_type': args.shell_type}\n    if args.norc:\n        shell_kwargs['ctx'] = {}\n    setattr(sys, 'displayhook', _pprint_displayhook)\n    shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)\n    from xonsh import imphooks\n    env = builtins.__xonsh_env__\n    if args.defines is not None:\n        env.update([x.split('=', 1) for x in args.defines])\n    if args.login:\n        env['XONSH_LOGIN'] = True\n    env['XONSH_INTERACTIVE'] = False\n    return args\n\n\ndef main(argv=None):\n    \"\"\"Main entry point for xonsh cli.\"\"\"\n    args = premain(argv)\n    env = builtins.__xonsh_env__\n    shell = builtins.__xonsh_shell__\n    if args.command is not None:\n        # run a single command and exit\n        shell.default(args.command)\n    elif args.file is not None:\n        # run a script contained in a file\n        if os.path.isfile(args.file):\n            with open(args.file) as f:\n                code = f.read()\n            code = code if code.endswith('\\n') else code + '\\n'\n            env['ARGS'] = [args.file] + args.args\n            code = shell.execer.compile(code, mode='exec', glbs=shell.ctx)\n            shell.execer.exec(code, mode='exec', glbs=shell.ctx)\n        else:\n            print('xonsh: {0}: No such file or directory.'.format(args.file))\n    elif not sys.stdin.isatty() and not args.force_interactive:\n        # run a script given on stdin\n        code = sys.stdin.read()\n        code = code if code.endswith('\\n') else code + '\\n'\n        code = shell.execer.compile(code, mode='exec', glbs=shell.ctx)\n        shell.execer.exec(code, mode='exec', glbs=shell.ctx)\n    else:\n        # otherwise, enter the shell\n        env['XONSH_INTERACTIVE'] = True\n        ignore_sigtstp()\n        shell.cmdloop()\n    postmain(args)\n\n\ndef postmain(args=None):\n    \"\"\"Teardown for main xonsh entry point, accepts parsed arguments.\"\"\"\n    del builtins.__xonsh_shell__\n\n\n@contextmanager\ndef main_context(argv=None):\n    \"\"\"Generator that runs pre- and post-main() functions. This has two iterations.\n    The first yields the shell. The second returns None but cleans\n    up the shell.\n    \"\"\"\n    args = premain(argv)\n    yield builtins.__xonsh_shell__\n    postmain(args)\n\n\n\nif __name__ == '__main__':\n    main()\n", "path": "xonsh/main.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"The main xonsh script.\"\"\"\nimport os\nimport sys\nimport builtins\nfrom argparse import ArgumentParser, ArgumentTypeError\nfrom contextlib import contextmanager\n\nfrom xonsh import __version__\nfrom xonsh.shell import Shell\nfrom xonsh.pretty import pprint\nfrom xonsh.jobs import ignore_sigtstp\n\ndef path_argument(s):\n    \"\"\"Return a path only if the path is actually legal\n\n    This is very similar to argparse.FileType, except that it doesn't return\n    an open file handle, but rather simply validates the path.\"\"\"\n\n    s = os.path.abspath(os.path.expanduser(s))\n    if not os.path.isfile(s):\n        raise ArgumentTypeError('\"%s\" must be a valid path to a file' % s)\n    return s\n\n\nparser = ArgumentParser(description='xonsh')\nparser.add_argument('-V', '--version',\n                    action='version',\n                    version='/'.join(('xonsh', __version__)),\n                    help='show version information and exit')\nparser.add_argument('-c',\n                    help=\"Run a single command and exit\",\n                    dest='command',\n                    required=False,\n                    default=None)\nparser.add_argument('-i',\n                    help='force running in interactive mode',\n                    dest='force_interactive',\n                    action='store_true',\n                    default=False)\nparser.add_argument('-l',\n                    help='run as a login shell',\n                    dest='login',\n                    action='store_true',\n                    default=False)\nparser.add_argument('--config-path',\n                    help='specify a custom static configuration file',\n                    dest='config_path',\n                    type=path_argument)\nparser.add_argument('--no-rc',\n                    help=\"Do not load the .xonshrc file\",\n                    dest='norc',\n                    action='store_true',\n                    default=False)\nparser.add_argument('-D',\n                    dest='defines',\n                    help='define an environment variable, in the form of '\n                         '-DNAME=VAL. May be used many times.',\n                    metavar='ITEM',\n                    nargs='*',\n                    default=None)\nparser.add_argument('--shell-type',\n                    help='What kind of shell should be used. '\n                         'Possible options: readline, prompt_toolkit. '\n                         'Warning! If set this overrides $SHELL_TYPE variable.',\n                    dest='shell_type',\n                    choices=('readline', 'prompt_toolkit'),\n                    default=None)\nparser.add_argument('file',\n                    metavar='script-file',\n                    help='If present, execute the script in script-file'\n                         ' and exit',\n                    nargs='?',\n                    default=None)\nparser.add_argument('args',\n                    metavar='args',\n                    help='Additional arguments to the script specified'\n                         ' by script-file',\n                    nargs='*',\n                    default=[])\n\n\ndef _pprint_displayhook(value):\n    if value is not None:\n        builtins._ = value\n        pprint(value)\n\n\ndef premain(argv=None):\n    \"\"\"Setup for main xonsh entry point, returns parsed arguments.\"\"\"\n    args = parser.parse_args(argv)\n    shell_kwargs = {'shell_type': args.shell_type}\n    if args.norc:\n        shell_kwargs['ctx'] = {}\n    if args.config_path:\n        shell_kwargs['ctx']= {'XONSHCONFIG': args.config_path}\n    setattr(sys, 'displayhook', _pprint_displayhook)\n    shell = builtins.__xonsh_shell__ = Shell(**shell_kwargs)\n    from xonsh import imphooks\n    env = builtins.__xonsh_env__\n    if args.defines is not None:\n        env.update([x.split('=', 1) for x in args.defines])\n    if args.login:\n        env['XONSH_LOGIN'] = True\n    env['XONSH_INTERACTIVE'] = False\n    return args\n\n\ndef main(argv=None):\n    \"\"\"Main entry point for xonsh cli.\"\"\"\n    args = premain(argv)\n    env = builtins.__xonsh_env__\n    shell = builtins.__xonsh_shell__\n    if args.command is not None:\n        # run a single command and exit\n        shell.default(args.command)\n    elif args.file is not None:\n        # run a script contained in a file\n        if os.path.isfile(args.file):\n            with open(args.file) as f:\n                code = f.read()\n            code = code if code.endswith('\\n') else code + '\\n'\n            env['ARGS'] = [args.file] + args.args\n            code = shell.execer.compile(code, mode='exec', glbs=shell.ctx)\n            shell.execer.exec(code, mode='exec', glbs=shell.ctx)\n        else:\n            print('xonsh: {0}: No such file or directory.'.format(args.file))\n    elif not sys.stdin.isatty() and not args.force_interactive:\n        # run a script given on stdin\n        code = sys.stdin.read()\n        code = code if code.endswith('\\n') else code + '\\n'\n        code = shell.execer.compile(code, mode='exec', glbs=shell.ctx)\n        shell.execer.exec(code, mode='exec', glbs=shell.ctx)\n    else:\n        # otherwise, enter the shell\n        env['XONSH_INTERACTIVE'] = True\n        ignore_sigtstp()\n        shell.cmdloop()\n    postmain(args)\n\n\ndef postmain(args=None):\n    \"\"\"Teardown for main xonsh entry point, accepts parsed arguments.\"\"\"\n    del builtins.__xonsh_shell__\n\n\n@contextmanager\ndef main_context(argv=None):\n    \"\"\"Generator that runs pre- and post-main() functions. This has two iterations.\n    The first yields the shell. The second returns None but cleans\n    up the shell.\n    \"\"\"\n    args = premain(argv)\n    yield builtins.__xonsh_shell__\n    postmain(args)\n\n\n\nif __name__ == '__main__':\n    main()\n", "path": "xonsh/main.py"}]}