# Tests fail after switching to raw mode for Builtin completion #QP2

**URL:** <https://forum.codecrafters.io/t/tests-fail-after-switching-to-raw-mode-for-builtin-completion-qp2/15580>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [November 25, 2025, 7:44pm UTC](https://forum.codecrafters.io/t/tests-fail-after-switching-to-raw-mode-for-builtin-completion-qp2/15580 "2025-11-25T19:44:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mirko-A](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mirko-a/32/19623_2.png) [@Mirko-A](https://forum.codecrafters.io/u/Mirko-A)\
**Post date:** [November 25, 2025, 7:44pm UTC](https://forum.codecrafters.io/t/tests-fail-after-switching-to-raw-mode-for-builtin-completion-qp2/15580/1 "2025-11-25T19:44:32Z")

</div>

After switching to raw mode (using the [crossterm - Rust](https://docs.rs/crossterm/0.29.0/crossterm/index.html) crate) in order to handle TAB completions, I am facing test failures for certain test cases (although trying the same thing locally doesn’t seem to run into the same issue).

Codecrafters CLI test logs:

```shell
❯ codecrafters test --previous
Initiating test run...

⏳ Turbo test runners busy. You are in queue.

Upgrade to skip the wait: https://codecrafters.io/turbo

Running tests on your code. Logs should appear shortly...

[compile] Compiling codecrafters-shell v0.1.0 (/app)
[compile] Finished `release` profile [optimized] target(s) in 1.85s
[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
[your-program] $
[tester::#OO8] ✓ Received prompt
[tester::#OO8] Test passed.

[tester::#CZ2] Running tests for Stage #CZ2 (Handle invalid commands)
[tester::#CZ2] Running ./your_program.sh
[your-program] $ invalid_mango_command
[tester::#CZ2] ^ Line does not match expected value.
[tester::#CZ2] Expected: "$ invalid_mango_command"
[tester::#CZ2] Received: "$ invalid_mango_commandError: Custom { kind: Other, error: "The cursor position could not be read within a normal durati"
[your-program] on" }
[your-program]
[tester::#CZ2] Assertion failed.
[tester::#CZ2] Test failed

View our article on debugging test failures: https://codecrafters.io/debug

```

Logs of when I run a similar command locally:

```shell
❯ cargo run
   Compiling codecrafters-shell v0.1.0 (REDACTED)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.26s
     Running `target/debug/codecrafters-shell`
$ some_invalid_command
some_invalid_command: command not found
$ exit

```

I found the piece of code where the error occurs in `crossterm`, it is [this](https://github.com/crossterm-rs/crossterm/blob/master/src/cursor/sys/unix.rs#L35-L59) function. It appears that crossterm isn’t able to access the `stdout` handle within the designated time, presumably because it is locked by another thread?

I’ve created a [repository](https://github.com/Mirko-A/codecrafters-shell-rust) where you can see/test my code.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [December 1, 2025, 2:51pm UTC](https://forum.codecrafters.io/t/tests-fail-after-switching-to-raw-mode-for-builtin-completion-qp2/15580/4 "2025-12-01T14:51:21Z")

</div>

Hey @Mirko-A, is the cursor position query strictly necessary? Removing it should resolve the issue.

You can re-run previous tests using [our CLI](https://docs.codecrafters.io/cli/installation) to make sure the earlier stages pass first:

```auto
codecrafters test --previous

```

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/5/e/5e34381ccdc18003e7c498c48bd322a18168f747.png)

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [December 6, 2025, 8:25pm UTC](https://forum.codecrafters.io/t/tests-fail-after-switching-to-raw-mode-for-builtin-completion-qp2/15580/6 "2025-12-06T20:25:48Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [December 11, 2025, 8:25pm UTC](https://forum.codecrafters.io/t/tests-fail-after-switching-to-raw-mode-for-builtin-completion-qp2/15580/7 "2025-12-11T20:25:55Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
