bash_kernel
bash_kernel copied to clipboard
Kernel crashes repetedly if $PS1 does not end in $
I was using a powerline like shell prompt and tried using the bash kernel. It repeatedly crashed, showing a traceback in the logs that led me to believe you were looking for a prompt that ended in "$"
Traceback (most recent call last):
File "/home/user/env/lib64/python3.5/site-packages/pexpect/expect.py", line 98, in expect_loop
incoming = spawn.read_nonblocking(spawn.maxread, timeout)
File "/home/user/env/lib64/python3.5/site-packages/pexpect/pty_spawn.py", line 466, in read_nonblocking
raise TIMEOUT('Timeout exceeded.')
pexpect.exceptions.TIMEOUT: Timeout exceeded.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib64/python3.5/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib64/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/elijah/envs/chkt/lib64/python3.5/site-packages/bash_kernel/__main__.py", line 3, in <module>
IPKernelApp.launch_instance(kernel_class=BashKernel)
File "/home/user/env/lib64/python3.5/site-packages/traitlets/config/application.py", line 657, in launch_instance
app.initialize(argv)
File "<decorator-gen-123>", line 2, in initialize
File "/home/user/env/lib64/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/home/user/env/lib64/python3.5/site-packages/ipykernel/kernelapp.py", line 457, in initialize
self.init_kernel()
File "/home/user/env/lib64/python3.5/site-packages/ipykernel/kernelapp.py", line 368, in init_kernel
user_ns=self.user_ns,
File "/home/user/env/lib64/python3.5/site-packages/traitlets/config/configurable.py", line 412, in instance
inst = cls(*args, **kwargs)
File "/home/user/envlib64/python3.5/site-packages/bash_kernel/kernel.py", line 81, in __init__
self._start_bash()
File "/home/user/env/lib64/python3.5/site-packages/bash_kernel/kernel.py", line 104, in _start_bash
line_output_callback=self.process_output)
File "/home/user/envlib64/python3.5/site-packages/bash_kernel/kernel.py", line 33, in __init__
prompt_change, extra_init_cmd=extra_init_cmd)
File "/home/user/env/lib64/python3.5/site-packages/pexpect/replwrap.py", line 51, in __init__
prompt_change.format(new_prompt, continuation_prompt))
File "/home/elijah/envs/chkt/lib64/python3.5/site-packages/pexpect/replwrap.py", line 61, in set_prompt
self.child.expect(orig_prompt)
File "/home/user/env/lib64/python3.5/site-packages/pexpect/spawnbase.py", line 327, in expect
timeout, searchwindowsize, async_)
File "/home/user/env/lib64/python3.5/site-packages/pexpect/spawnbase.py", line 355, in expect_list
return exp.expect_loop(timeout)
File "/home/user/env/lib64/python3.5/site-packages/pexpect/expect.py", line 106, in expect_loop
return self.timeout(e)
File "/home/user/envlib64/python3.5/site-packages/pexpect/expect.py", line 70, in timeout
raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7ff254664240>
command: /usr/bin/bash
args: [b'/usr/bin/bash', b'--rcfile', b'/home/user/env/lib64/python3.5/site-packages/pexpect/bashrc.sh']
buffer (last 100 chars): '5;250;48;5;240msfw\xa0\x1b[0;38;5;245;48;5;240;22m\ue0b1\xa0\x1b[0;38;5;252;48;5;240;1mchkt\xa0\x1b[0;38;5;240;49;22m\ue0b0\xa0\x1b[0m'
before (last 100 chars): '5;250;48;5;240msfw\xa0\x1b[0;38;5;245;48;5;240;22m\ue0b1\xa0\x1b[0;38;5;252;48;5;240;1mchkt\xa0\x1b[0;38;5;240;49;22m\ue0b0\xa0\x1b[0m'
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 28695
child_fd: 46
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
0: re.compile("\$")
It started working once I disabled my powerline by commenting out the part of my .bashrc that makes me use thep powerline and putting a more "traditional" PS1 prompt in there. i.e. export PS1="$USER@$HOSTNAME:${PWD} \$ "
Ideally, I'd like not to have to do this to use this plugin, which I really like the idea of!
I took a quick look and it was not immediately obvious how this regex is getting formed because it is not verbatim in the code. If you have tips on how it gets made, I would make a PR to fix this.
It's supposed to override your PS1 by starting bash with this script. It might be missing something, though. I'm just working on fixing an issue where PROMPT_COMMAND overrides it - https://github.com/pexpect/pexpect/pull/459