Shell: Expected prompt ("$ ") but received ""

I’m stuck on Stage #CZ2.

I am randomly failing tests without changing my code. Based on similar posts, I tried codecrafters test --previous and ./your_program.sh, but both also randomly fail. My code is simple, so I don’t think it is a code issue.

Below are logs from ./your_program.sh (had to abort due to hanging command):

❯ ./your_program.sh
^CEnvironment creation aborted.
Error: An error occurred while removing /home/wckmoss_linux/.local/share/virtualenvs/codecrafters-shell-python-8beZXhxl!
[Errno 2] No such file or directory: '/home/wckmoss_linux/.local/share/virtualenvs/codecrafters-shell-python-8beZXhxl'

Below are the logs from codecrafters test --previous:

[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.

Debug = true

[tester::#OO8] Running tests for Stage #OO8 (Print a prompt)
[tester::#OO8] Running ./your_program.sh
[tester::#OO8] Expected prompt ("$ ") but received ""
[tester::#OO8] Assertion failed.
[tester::#OO8] Test failed

Below is my python code:

import sys


def main():
    # Uncomment this block to pass the first stage
    sys.stdout.write("$ ")
    sys.stdout.flush()

    # Wait for user input
    cmd = input()
    sys.stdout.write(f"{cmd}: command not found\n")


if __name__ == "__main__":
    main()

I had to globally install pipenv to run the shell script. Maybe this is a python env issue?

Hi @qwet11, thanks for highlighting the issue! We’ll investigate the issue and keep you updated with any progress.

In the meanwhile, you can try deleting sys.stdout.write and editing input:

cmd = input("$ ")