Skip to content

Version 0.9.1 seems to have broken prompt handling in some cases #142

Description

@thomasjm

Starting at 0.9.1, I can no longer start a kernel. I'm using Papermill 2.5.0 and Bash 5.2, both provided by Nixpkgs. I get error output like the below, which seems to involve the prompt regex.

The likely commit seems to be 9049a84

CC @kdm9

When I launch the Bash binary normally with the indicated rcfile, it seems fine (the prompt is just a single $).

EDIT: actually, it seems this may be because of a lack of this patch: #69. This PR was previously incorporated into Nixpkgs, but was removed when updating to 0.9.1. Not sure why, perhaps it didn't merge cleanly with 9049a84.

Starting kernel: ['/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/bin/python', '-m', 'bash_kernel', '-f', '/tmp/tmp5r68mz62.json']
Connecting to: tcp://127.0.0.1:39427
connecting iopub channel to tcp://127.0.0.1:53175
Connecting to: tcp://127.0.0.1:53175
connecting shell channel to tcp://127.0.0.1:59761
Connecting to: tcp://127.0.0.1:59761
connecting stdin channel to tcp://127.0.0.1:33515
Connecting to: tcp://127.0.0.1:33515
connecting heartbeat channel to tcp://127.0.0.1:56607
Using selector: EpollSelector
connecting control channel to tcp://127.0.0.1:39427
Connecting to: tcp://127.0.0.1:39427
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/bash_kernel/__main__.py", line 3, in <module>
    IPKernelApp.launch_instance(kernel_class=BashKernel)
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/traitlets/config/application.py", line 1045, in launch_instance
    app.initialize(argv)
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/ipykernel/kernelapp.py", line 707, in initialize
    self.init_kernel()
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/ipykernel/kernelapp.py", line 555, in init_kernel
    kernel = kernel_factory(
             ^^^^^^^^^^^^^^^
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/traitlets/config/configurable.py", line 555, in instance
    inst = cls(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/bash_kernel/kernel.py", line 104, in __init__
    self._start_bash()
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/bash_kernel/kernel.py", line 130, in _start_bash
    self.bashwrapper = IREPLWrapper(child, u'\$', prompt_change, self.unique_prompt,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/bash_kernel/kernel.py", line 45, in __init__
    replwrap.REPLWrapper.__init__(self, cmd_or_spawn, orig_prompt,
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/pexpect/replwrap.py", line 55, in __init__
    self._expect_prompt()
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/bash_kernel/kernel.py", line 72, in _expect_prompt
    pos = self.child.expect_list([re.compile(x) for x in prompts], timeout=timeout)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/pexpect/spawnbase.py", line 372, in expect_list
    return exp.expect_loop(timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)
           ^^^^^^^^^^^^^^^
  File "/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/pexpect/expect.py", line 144, in timeout
    raise exc
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7fda869c3a10>
command: /nix/store/r9h133c9m8f6jnlsqzwf89zg9w0w78s8-bash-5.2-p15/bin/bash
args: [b'/nix/store/r9h133c9m8f6jnlsqzwf89zg9w0w78s8-bash-5.2-p15/bin/bash', b'--rcfile', b'/nix/store/x35v2zqxli4bvnxksj487clhrpdwbh0m-python3-3.11.8-env/lib/python3.11/site-packages/pexpect/bashrc.sh']
buffer (last 100 chars): 'PROMPT_BXYHNBYPIEVG\\[\\]>'
before (last 100 chars): 'PROMPT_BXYHNBYPIEVG\\[\\]>'
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 46662
child_fd: 47
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('(\\(\\w+\\) )?PROMPT_BXYHNBYPIEVG>')
    1: re.compile('PROMPT_BXYHNBYPIEVG\\+')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions