# Bug in "Build you own Shell" - Autocompletion

**URL:** <https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [April 20, 2025, 7:08pm UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108 "2025-04-20T19:08:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikkel-larsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mikkel-larsen/32/9158_2.png) [@mikkel-larsen](https://forum.codecrafters.io/u/mikkel-larsen)\
**Post date:** [April 20, 2025, 7:08pm UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/1 "2025-04-20T19:08:49Z")

</div>

I cannot get past the first step in the Autocompletion module in Build your own Shell. It seems there is a bug in the test script as can be seen below:

 ![Skærmbillede 2025-04-20 kl. 21.08.29](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/a/accc7381cd096f5ced7ae9cf1633a4b096e5780b.png)

For some reason it seems that the “Expected” string and the test input does not match (input’s missing the letter “b”)

---

<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:** [April 21, 2025, 6:33am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/4 "2025-04-21T06:33:02Z")

</div>

Hey @mikkel-larsen, it doesn’t appear to be a bug on our end. You can try running the program locally to verify that the letter **b** is indeed being swallowed by readline:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/c/c04339ffddf1d8fbcfa8d5fc34ff4d20ae0048f6.png)

The issue seems to stem from this line: `readline.parse_and_bind("bind ^I rl_complete")`. Removing it allows your code to pass all tests.

---

<div class="post-metadata">

**Author:** ![mikkel-larsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mikkel-larsen/32/9158_2.png) [@mikkel-larsen](https://forum.codecrafters.io/u/mikkel-larsen)\
**Post date:** [April 21, 2025, 7:28am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/6 "2025-04-21T07:28:18Z")

</div>

That’s strange. It works for me when I try locally.

 ![Skærmbillede 2025-04-21 kl. 09.25.44](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/8/8c85b94c53fa76ef955a5e1f397073ffc34d655c.png)

I can’t, however, use tab-completion if I remove `readline.parse_and_bind("bind ^I rl_complete")`. Though I can see that the tests run successfully on your end without that line.

But that means that I cannot use tab-completion on my machine for the rest of the assignments if I want to complete this ☹

---

<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:** [April 21, 2025, 7:37am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/7 "2025-04-21T07:37:20Z")

</div>

That’s definitely peculiar. By the way, how did you come across the workaround `"bind ^I rl_complete"`? Curious why **Control-I** would map to Tab. 🤔

* * *

To help confirm whether you’re using **GNU Readline** or **libedit** under the hood, could you share the result of running `print(readline. __doc__ )`?

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/1/181528900356a8ac8e03e66f8daf781445e50e26.png)

---

<div class="post-metadata">

**Author:** ![mikkel-larsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mikkel-larsen/32/9158_2.png) [@mikkel-larsen](https://forum.codecrafters.io/u/mikkel-larsen)\
**Post date:** [April 21, 2025, 8:52am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/8 "2025-04-21T08:52:16Z")

</div>

Definitely!

 ![Skærmbillede 2025-04-21 kl. 09.49.06](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/0/0816ec9041ca1e814eb08bff54ff04a06678d7b8.png)

And I agree, I was sceptical of the command when I found it (on Reddit), but as it worked I admit I did not think further of it.

> **[Reddit - The heart of the internet](https://www.reddit.com/r/learnpython/comments/142koeu/comment/jnbr4yz/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button&rdt=57618)**

---

<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:** [April 21, 2025, 8:54am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/9 "2025-04-21T08:54:41Z")

</div>

Looks like your readline is using **libedit** instead of **GNU Readline**.

The issue can be resolved by installing GNU Readline:

```auto
brew install readline

```

---

<div class="post-metadata">

**Author:** ![mikkel-larsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mikkel-larsen/32/9158_2.png) [@mikkel-larsen](https://forum.codecrafters.io/u/mikkel-larsen)\
**Post date:** [April 21, 2025, 9:09am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/10 "2025-04-21T09:09:50Z")

</div>

Was already installed. Do I need to do something to make it the default instead of libedit?

---

<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:** [April 21, 2025, 9:24am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/11 "2025-04-21T09:24:06Z")

</div>

My Python is installed via Anaconda, and I just confirmed that readline is installed through conda as well:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/3/38a52990729e6c1154aa2944625e525a0f667835.png)

Not sure if pip install would work in this case.

---

<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:** [April 21, 2025, 9:28am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/12 "2025-04-21T09:28:51Z")

</div>

@mikkel-larsen You might be able to move that workaround to `~/.editrc` instead of including it in your code:

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

> **[readline — GNU readline interface](https://docs.python.org/3/library/readline.html)**
>
> The readline module defines a number of functions to facilitate completion and reading/writing of history files from the Python interpreter. This module can be used directly, or via the rlcompleter...

---

<div class="post-metadata">

**Author:** ![mikkel-larsen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/mikkel-larsen/32/9158_2.png) [@mikkel-larsen](https://forum.codecrafters.io/u/mikkel-larsen)\
**Post date:** [April 21, 2025, 9:41am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/13 "2025-04-21T09:41:37Z")

</div>

the .editrc config file did the trick for me!

Thank you for the help.

---

<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:** [April 26, 2025, 9:42am UTC](https://forum.codecrafters.io/t/bug-in-build-you-own-shell-autocompletion/9108/14 "2025-04-26T09:42:20Z")

</div>

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